Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Download Folder from Google Drive

Status
Not open for further replies.

lardman363

Automotive
Joined
Feb 8, 2013
Messages
173
Location
US
Hello,
I need to loop through and collect properties from folders and files on Google Drive. I have a macro that is working on folders/files on my local, so i thought it would be best to run the macro, temporarily download the file structure from Google Drive, then delete the temporary folder at the end of the macro.

I was wondering if there is a way to download a folder from Google Drive, using VBA. I found a bit of code that works for downloading a file...but I need the entire structure and I am not sure how to modify it for a folder. Any help would be greatly appreciated:)

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 = "IndividualFileIDHere"

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

(Source1, Source2)
 
I cannot get to that info, it is "premium content".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top