Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

Help with script to login to gmail. Excel 2013.VB 7.1. Button will not click

$
0
0
TLDR:Need help with clicking the NEXT button, please.

I was hoping somebody could help, please. I am a newcomer to VB but have fallen in love with it already.

I am attempting to compile a script that will allow me to automatically login to gmail. This is just one part of a longer script but is essential. I found a script online that allows me to partially login and wanted some help in completing the process.

The script I am using is
Code:

Private Sub CommandButton1_Click()



  Const cURL = "https://accounts.google.com/ServiceLogin?service=mail&continue=https://mail.google.com/mail/#identifier" 'Enter the web address here
    Const cUsername = "XXXXXX" 'Enter your user name here
   
   
    Dim IE As InternetExplorerMedium
    Dim doc As HTMLDocument
    Dim LoginForm As HTMLFormElement
    Dim UserNameInputBox As HTMLInputElement
    Dim PasswordInputBox As HTMLInputElement
    Dim SignInButton As MSHTML.HTMLOptionButtonElement
    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("Email")
    UserNameInputBox.Value = cUsername
   
   


   
    '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("signIn")
    SignInButton.Click
   
   
           
    'Wait for the new page to load
   
    Do While IE.ReadyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
   
    End Sub

The script opens IE and goes to the correct page, enters the correct login but I cannot get it to click the Next Button

The error message that comes up is "Runtime error 13 Type Mismatch"

And the debugger stops at this line of code.
Code:

Set SignInButton = LoginForm.elements("signIn")
    SignInButton.Click

So can anybody help me amend this bit of code so that the Next button is automatically clicked?

The webpage looks like this

Name:  nextbutton.jpg
Views: 79
Size:  16.6 KB

Hopefully, this is enough information. And thank you for reading this far.

Harry
Attached Images
 

Viewing all articles
Browse latest Browse all 688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>