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 Downloading a file via FTP in code

Jeff,

there's an API call I use a lot. It should work with an FTP site.

'API file download call
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, strTargetFolder As String)
Dim lReturn As Long
Dim strFullURL As String
Dim strLocation As String

strFullURL = "http://100.100.100.100/" & strFileName
strLocation = strTargetFolder & strFileName

On Error Resume Next
SetAttr strLocation, vbNormal
On Error GoTo 0

lReturn = URLDownloadToFile(0, strFullURL, strLocation, 0, 0)
If lReturn < 0 Then msgbox "download failed"
End Sub

Robin Hammond
www.enhanceddatasystems.com

"Jeff Standen" wrote in message
...
Hi all,

I'd like to download a file to a specified directory in code, without
resorting to what I currently do, which is writing a text file, saving it
and using Shell() to call the Windows FTP program. Is there a simpler way

to
do this?

Cheers,

Jeff
Using Win XPPro & Office 2003