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.
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&ltmpl=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.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Anybody, have any ideas or possibly better way to keep an updated file somewhere multiple people can access it. and do it through VBA so it will be a button to upload and download the latest version?

Thank you.
 
Upvote 0
I'm not really expert enough in html objects but reading your question again, I wonder that you don't simply upload to Google docs the normal way. Then you can then simply access and edit the document simultaneously - that's the whole point of it really. But you are supposed leave the document online - none of this download/upload stuff. If you try to download/upload a file - you lose the ability to edit and work on the file simultaneously, which is the whole point of Google Docs.

I find Google Docs less sophisticated with formatting as Word is, but you can do all your basic word processing. You have to get used to some quirks.

Office 2007 ships with a "Live" addin which is similar in nature - a shared document space. I'm not sure if it works with 2003.
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,072
Latest member
DW Draft

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