KMacattack
New Member
- Joined
- Nov 24, 2008
- Messages
- 11
I am trying to upload a file to google docs,
i have the code to login and get to the upload page and then open up the browse to a location on your computer, but once that window pops up to enter in the location of the file, i dont know how to input the location into that "choose a file to upload" box.
I am also getting a permission denied when i try to open the browse button, the first time i run the code, but when i run it a second time there is no problem.
below is what i have so far for code.
any help would be great.
Thanks in advance.
i have the code to login and get to the upload page and then open up the browse to a location on your computer, but once that window pops up to enter in the location of the file, i dont know how to input the location into that "choose a file to upload" box.
I am also getting a permission denied when i try to open the browse button, the first time i run the code, but when i run it a second time there is no problem.
below is what i have so far for code.
Code:
Option Explicit
Public Enum IE_READYSTATE
Uninitialised = 0
Loading = 1
Loaded = 2
Interactive = 3
complete = 4
End Enum
Sub Test()
Const cURL = "http://docs.google.com/DocAction?action=updoc&hl=en"
cUserID = "XXXX" 'REPLACE XXXX WITH YOUR USER ID
cPwd = "XXXX" 'REPLACE YYYY WITH YOUR PASSWORD
Dim ie As Object
Dim doc As HTMLDocument
Dim PageForm As HTMLFormElement
Dim UserIdBox As HTMLInputElement
Dim PasswordBox As HTMLInputElement
Dim LocDoc As HTMLInputElement
Dim SubmitButton As HTMLInputButtonElement
Dim FormButton As HTMLInputButtonElement
Dim Brse As HTMLInputButtonElement
Dim Elem As IHTMLElement
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate cURL
'Wait for initial page to load
Do While ie.busy Or Not ie.readyState = IE_READYSTATE.complete: DoEvents: Loop
Set doc = ie.document
'Output HTML tags to debug window
Debug.Print "Login page: " & ie.LocationURL
'Get the only form on the page
Set PageForm = doc.forms(0)
If cUserID = "XXXX" Then cUserID = InputBox("Enter in User Name: ")
If cPwd = "XXXX" Then cPwd = InputBox("Enter in password: ")
'Makes sure the IE window is at the Login Screen
If ie.LocationURL = "https://www.google.com/accounts/ServiceLogin?service=writely&passive=true&nui=1&continue=http%3A%2F%2Fdocs.google.com%2FDocAction%3Faction%3Dupdoc%26hl%3Den&followup=http%3A%2F%2Fdocs.google.com%2FDocAction%3Faction%3Dupdoc%26hl%3Den<mpl=homepage&rm=false" Then
'Get the UseerId ("Email")
Set UserIdBox = PageForm.elements("Email")
UserIdBox.Value = cUserID
'Get the password textbox ("Passwd")
Set PasswordBox = PageForm.elements("Passwd")
'Set the password
PasswordBox.Value = cPwd
'Get the form submit button and click it to navigate to next page
Set FormButton = PageForm.elements("signin")
FormButton.Click
'Wait for the new page to load
Do While ie.busy Or Not ie.readyState = IE_READYSTATE.complete: DoEvents: Loop
End If
'Get the HTML document of the new page
Set doc = ie.document
'Get the LocDoc textbox to upload file ("UploadedFile")
' Set LocDoc = PageForm.elements("uploadedFile")
'the path for of file to upload
' LocDoc.Value = "C:\Documents and Settings\User\Desktop\My Excel.xls"
'get the browse button
Set Brse = PageForm.elements("uploadedFile")
'click the browse button
Brse.Click
'Get the submit button
Set SubmitButton = PageForm.elements("saveChanges")
'Clicks the submit button
SubmitButton.Click
End Sub
any help would be great.
Thanks in advance.