问题
I have found different scripts for Java, C#, and Access VBA for uploading a file to Google Drive. But the only thing I have found with Excel VBA, is a script saving the file in your local Google Drive folder and then wait for the application to sync it.
Is it possible to somehow upload the Excel file directly to a folder that has been shared with me? If yes, how?
回答1:
I actually managed to do this.
First, you need to create credentials. Follow this guide: https://updraftplus.com/support/configuring-google-drive-api-access-in-updraftplus/
- The credentials should be
OAuth Client ID
- Application Type: Other
Secondly, I downloaded this Access VBA code found here https://stackoverflow.com/a/34627231/1042624
Afterwards, in the Access document, there will be a settings box. You need to fill in the information about your account and the credentials from step 1 here. Then you can use the upload button, and it will work. However, if you want to use this in Excel and without the form boxes, then you have to step through the code and find where the settings form boxes´ info are being used. It takes quite a while, and the code is too long to post here. But now you at least have the information on how to do it.
NB: I still did not crack the 2-step verification that I have enabled.
来源:https://stackoverflow.com/questions/38762322/upload-excel-document-to-shared-folder-on-google-drive-with-excel-vba