View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Robin Hammond[_2_] Robin Hammond[_2_] is offline
external usenet poster
 
Posts: 575
Default download a file from a webpage with VBA

RB,

You'll need to know the ip address of the source machine and change the
strFullURL line.

Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, ByVal strURL As String, _
ByVal strFileName As String, ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long

Public Sub GetInternetFile(strFileName As String)

Dim lReturn As Long
Dim strFullURL As String
Dim strLocation as string

strFullURL = "http:\\nnn.nnn.nnn.nnn\subfolder\" & strFileName
strLocation = environ("Temp") & "\" & strFileName

lReturn = URLDownloadToFile(0, strFullURL, strLocation, 0, 0)

If lReturn < 0 Then call msgbox("failed")

End Sub

Robin Hammond
www.enhanceddatasystems.com

"RB Smissaert" wrote in message
...
How do I download a file from a webpage with VBA?
I know how to open a hyperlink with the FollowHyperlink function, but I
can't find any information about how to download a file to a specified
folder.
The idea is to automatically update an Excel add-in from a webpage.
Thanks for any advice.

RBS