2013-08-30 333 views
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它完美,但與谷歌驅動器鏈接它沒有。我如何才能使它與谷歌驅動器鏈接工作?

回答

-1
+0

雖然這種聯繫可以回答這個問題,最好是在這裏有答案的關鍵部位和提供鏈接供參考。如果鏈接頁面更改,則僅鏈接答案可能會失效。來自網站的 – Shadwell

+0

: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

相關問題