Quote Originally Posted by RhinoBull View Post
Are you sure you suppose to get err.number 76?
Comment out "If Err.Number = 76 Then" and do debug.print err.number instead so you can get actual error number.
Then make your decision how to handle it based on what you find.

Also, few comments regarding your code:

- try not to use labels (start, etc...)
- try not to use reserved words (Err) for anything you do within your code...
The error isn't being handled so I don't see how commenting out the if statement will have any effect. (I went line by line so I am pretty sure the label isn't being reached.)
Try the following modifications:

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
You may also want to check out the URLDownloadToFile API function. Search this forum for examples of using it.
Thank you. I'll try that. And thanks for the API, I'll look into it.