0

when excecuted it gives an error 424 object required
what i intend to do is download a pdf file to a location in my pc

DoEvents

    If DownloadFile(ie3.locationurl, App.Path) Then
        MsgBox "Download Complete", _
            vbOKOnly Or vbInformation, _
            "Done"
    End If


' Download a file. Return True if we are successful.
Private Function DownloadFile(ByVal source_file As String, ByVal dest_file As String) As Boolean
Dim bytes() As Byte
Dim fnum As Integer

    ' Get the file's contents.
    On Error GoTo DownloadError
    bytes() = Inetftp.OpenURL(source_file, icByteArray)

    ' Remove the file if it exists.
    On Error Resume Next
    Kill dest_file
    On Error GoTo DownloadError

    ' Write the contents into the destination file.
    fnum = FreeFile
    Open dest_file For Binary Access Write As #fnum
    Put #fnum, , bytes()
    Close #fnum

    DownloadFile = True
    Exit Function

DownloadError:
    MsgBox "Error " & Err.Number & _
        " downloading file '" & _
        source_file & "' to '" & _
        dest_file & "'." & vbCrLf & Err.Description, _
        vbExclamation Or vbOKOnly, _
        "Download Error"
    DownloadFile = False
    Exit Function
End Function
1
Contributor
2
Replies
3
Views
8 Years
Discussion Span
Last Post by lalchetian
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.