+ Reply to Thread
Results 1 to 1 of 1

Macro to save file in IE or to open with Chrome

Hybrid View

  1. #1
    Registered User
    Join Date
    08-28-2014
    Location
    Portugal
    MS-Off Ver
    2013
    Posts
    1

    Macro to save file in IE or to open with Chrome

    Hi

    I have this code working in IE but when i try to download a file from the website IA ask "Open Save or Cancel". I want to save automatically the file but dont find code to do it.

    May you Help? Itīs possible to make my code work with Chrome? In this case the file is automatically downloaded.

    Sub Login()
    
    Const cURL = "http://teste.com" 'Enter the web address here
    Const cUsername = "usertest" 'Enter your user name here
    Const cPassword = "passteste" 'Enter your Password here
    
    Dim IE As InternetExplorer
    Dim doc As HTMLDocument
    Dim LoginForm As HTMLFormElement
    Dim UserNameInputBox As HTMLInputElement
    Dim PasswordInputBox As HTMLInputElement
    Dim SignInButton As HTMLInputButtonElement
    Dim HTMLelement As IHTMLElement
    Dim qt As QueryTable
    
    Set IE = New InternetExplorer
    
    IE.Visible = True
    IE.navigate cURL
    
    'Wait for initial page to load
    
    Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
    
        Set doc = IE.document
    
    'Get the only form on the page
    
        Set LoginForm = doc.forms(0)
    
    'Get the User Name textbox and populate it
        'input name="Email" id="Email" size="18" value="" class="gaia le val" type="text"
    
        Set UserNameInputBox = LoginForm.elements("username")
        UserNameInputBox.Value = cUsername
    
    'Get the password textbox and populate it
    'input name="Passwd" id="Passwd" size="18" class="gaia le val" type="password"
    
    
        Set PasswordInputBox = LoginForm.elements("Password")
        PasswordInputBox.Value = cPassword
    
    'Get the form input button and click it
    'input class="gaia le button" name="signIn" id="signIn" value="Sign in" type="submit"
    
        Set SignInButton = LoginForm.elements("loginbtn")
        SignInButton.Click
    
    'Wait for the new page to load
    
        Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
    
    End Sub
    Last edited by JBeaucaire; 11-26-2014 at 06:45 PM. Reason: Added Code Tags / Corrected title. Please read and follow the forum rules! Link above in the menu bar.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1