Try the following modifications:
You may also want to check out the URLDownloadToFile API function. Search this forum for examples of using it.Code:Public Sub DownloadFile(ByRef sURL As String, ByRef sFilePath As String) Dim bytData() As Byte Dim FN As Integer Dim sDir As String bytData() = Form1.inetDownload.OpenURL(sURL, icByteArray) 'Extract the path component of the fully-qualified file path sDir = Left$(sFilePath, InStrRev(sFilePath, "\") - 1&) If Not PathExists(sDir) Then MkDirEx sDir '<-- Click this ElseIf FileExists(sFilePath) Then Kill sFilePath End If FN = FreeFile Open sFilePath For Binary Access Write As FN Put #FN, , bytData() Close FN End Sub Public Function FileExists(ByRef sFile As String) As Boolean On Error Resume Next FileExists = (GetAttr(sFile) And vbDirectory) <> vbDirectory End Function Public Function PathExists(ByRef sPath As String) As Boolean On Error Resume Next PathExists = (GetAttr(sPath) And vbDirectory) = vbDirectory End Function




Reply With Quote