我正在尝试从谷歌驱动器下载文件。我检查了这两个例子,但没有人适合我:
Sub DownloadPDF()
Dim FileNum As Long
Dim FileData() As Byte
Dim MyFile As String
Dim WHTTP As Object
On Error Resume Next
Set WHTTP = CreateObject("WinHTTP.WinHTTPrequest.5")
If Err.Number <> 0 Then
Set WHTTP = CreateObject("WinHTTP.WinHTTPrequest.5.1")
End If
On Error GoTo 0
MyFile = "https://docs.google.com/a/dink.eu/file/d/0B2P4BoDG6mdejjesiEEFMNHN0cFU/edit?usp=sharing"
WHTTP.Open "GET", MyFile, False
WHTTP.send
FileData = WHTTP.ResponseBody
Set WHTTP = Nothing
If Dir("C:\MyDownloads", vbDirectory) = Empty Then MkDir "C:\MyDownloads"
FileNum = FreeFile
Open "C:\MyDownloads\binder.pdf" For Binary As #FileNum
Put #FileNum, 1, FileData
Close #FileNum
MsgBox "Open the folder [ C:\MyDownloads ] for the downloaded file..."
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
Sub DownPDF()
Dim ss As String
Dim ts As String
ss = "https://docs.google.com/a/dink.eu/file/d/0B46Ux_7O0o-4RdefsERgaEHU2YtZXM/edit?pli=1"
ts = "c:\MyDownloads\Stryker experience binder.pdf"
URLDownloadToFile 0, ss, ts, 0, 0
End Sub
使用普通链接,例如,如果我使用以下链接http://www.bigfoto.com/sites/main/tree-winter-xxx.JPG,它可以正常工作,但谷歌驱动器链接却没有。如何使其与谷歌驱动器链接一起使用?
答案 0 :(得分:-1)