2015-05-29 77 views
-2
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _ 
        "URLDownloadToFileA" (_ 
         ByVal pCaller As Long, _ 
         ByVal szURL As String, _ 
         ByVal szFileName As String, _ 
         ByVal dwReserved As Long, _ 
         ByVal lpfnCB As Long) As Long 

Sub AAA()             
    Dim SourceName As String 
    Dim Destination As String 
    Dim R As Long 

    SourceName = "http://www.cpearson.com/zips/modDownloadFile.zip" 
    Destination = "D:\Test\modDownloadFile.zip" 
    R = URLDownloadToFile(0&, SourceName, Destination, 0&, 0&) 
    If R = 0 Then 
     Debug.Print "success" 
    Else 
    Debug.Print "error: " & CStr(Err.LastDllError) 
    End If 
End Sub         
+0

問題是什麼?你正在運行64位Excel嗎? – Jeeped

回答

0

請嘗試URLDownloadToFile(0, SourceName, Destination, 0, 0)而不是URLDownloadToFile(0&, SourceName, Destination, 0&, 0&)