0
我想从谷歌驱动器下载文件。我检查了这两个例子,但没有人对我的作品:从谷歌驱动器下载文件
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它完美,但与谷歌驱动器链接它没有。我如何才能使它与谷歌驱动器链接工作?
虽然这种联系可以回答这个问题,最好是在这里有答案的关键部位和提供链接供参考。如果链接页面更改,则仅链接答案可能会失效。来自网站的 – Shadwell
:http://thebiobucket.blogspot.hu/2011/10/how-to-link-to-google-docs-for-download.html:“https://docs.google.com/uc?export = download&id = YourIndividualID 您可以在“共享...” - 对话框中复制您的个人文件ID。在这里您还需要将共享设置设置为“公开”或“具有链接的任何人”“ – gyap