×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

VBA Download Folder from Google Drive

VBA Download Folder from Google Drive

VBA Download Folder from Google Drive

(OP)
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 = "https://docs.google.com/uc?export=download&id=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)

RE: VBA Download Folder from Google Drive

(OP)
I cannot get to that info, it is "premium content".

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources