http://www.vbaspnew.com/
测试过,可以下载
使用 URLDownloadToFile 这个API可以实现你想要的功能。'// 定义
'// 下载网络上的一个文件到本地
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
'// 下载一个文件到本地
Public Function DownloadFile(ByVal strURL As String, ByVal strFile As String) As Boolean
Dim lngReturn As Long
lngReturn = URLDownloadToFile(0, strURL, strFile, 0, 0)
If lngReturn = 0 Then DownloadFile = True
End Function
Private Sub Command1_Click()
Debug.Print DownloadFile("http://zhidao.baidu.com/question/12376048.html", "D:\1.html")
End Sub
后台下载声明:
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
'//调用
然后在代码里直接调用:
Call URLDownloadToFile(0, "网页地址", "保存到本地文件名和地址", 0, 0)
如
Call URLDownloadToFile(0, "http://www.baidu.com/", "c:\1.htm", 0, 0)
相当于另存为
声明:
Private Declare Function DoFileDownload Lib "shdocvw.dll"(ByVal lpszFile As String) As Long
'//调用
然后在代码里直接调用:
Dim gourl As String
AdUrl = StrConv("网页地址", vbUnicode)
Call DoFileDownload(gourl)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)