VBA to Log into Googles DropBox and submit Files

dvolsche

New Member
Joined
Dec 18, 2016
Messages
1
Hi every one, I'm hoping someone on here can help me.

I'm using an online google site that allows you to upload files, which are linked to Dropbox, which is then linked to my google drive, allowing direct uploads to my google drive if you have the website address
I'm familiar with vba's but i'm completely lost with this. I'm hoping to have a vba which will select the "choose file button", past a predetermined path or file name into the pop up browse window and then have the vba hit enter, and proceed to click the submit button. Is this possible ?

Below is my current code as well as the website address. As you'll see the website is super-basic so it should be to hard right ? Im lost any insight would be great.

Dim HTMLDoc As HTMLDocument
Dim MyBrowser As InternetExplorer


Sub Upload()


Dim MyHTML_Element As IHTMLElement
Dim MyURL As String
On Error GoTo Err_Clear
MyURL = "https://script.google.com/macros/s/AKfycbznalI3P2XuT5PubzdP7XJ_6X3tneK4Xjhlss_RVum-eCeJUkU/exec"
Set MyBrowser = New InternetExplorer
MyBrowser.Silent = True
MyBrowser.navigate MyURL
MyBrowser.Visible = True
Application.Wait Now() + TimeValue("00:00:05")
Do
Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = MyBrowser.document

HTMLDoc.all.myName.Value = "NAME" 'Name here
For Each MyHTML_Element In HTMLDoc.getElementsByTagName("input")
If MyHTML_Element.Type = "Submit" Then MyHTML_Element.Click: Exit For
Next


Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If
End Sub



Below is the link to the site
https://script.google.com/macros/s/AKfycbznalI3P2XuT5PubzdP7XJ_6X3tneK4Xjhlss_RVum-eCeJUkU/exec
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
You can't do it like this. You cannot upload files using Internet Explorer automation - it's a security feature of IE, you cannot automate the File input type.

You'll need to look for another solution, though it's not likely to be simple
 
Upvote 0
You can emulate a file upload HTML form with < input type=file> by sending a multipart/form-data POST request - see Automated file upload using IE, without user interaction - VBA. The example uses IE, and you can also use XMLhttp or WinHttpRequest.

You can upload files to Google Drive using the Drive API - https://developers.google.com/drive/v3/web/manage-uploads - however it is very complicated. You have to enable the Drive API in the Google API Console and register your application (VBA program). The VBA program must also authorise the requests - https://developers.google.com/drive/v3/web/about-auth.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,713
Messages
6,174,043
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top