Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-20-2015, 01:42 AM
saurabhlotankar saurabhlotankar is offline Require assistance in writing code to login to webmail account. Windows XP Require assistance in writing code to login to webmail account. Office 2010 32bit
Novice
Require assistance in writing code to login to webmail account.
 
Join Date: May 2015
Posts: 29
saurabhlotankar is on a distinguished road
Default Require assistance in writing code to login to webmail account.

Hi All,

I am trying to login to webmail account througha VBA macro.

Complete code is working fine except clicking on sign in button. Please assist.

My code:

Sub test()
' open IE, navigate to the desired page and loop until fully loaded
Set IE = CreateObject("InternetExplorer.Application")
my_url = "https://www.google.com"

With IE
.Visible = True
.Navigate my_url
'.Top = 50
'.Left = 530
'.Height = 400
'.Width = 400

Do Until Not IE.Busy And IE.readyState = 4
DoEvents
Loop



End With

' Input the userid and password
IE.Document.getElementById("username").Value = "*******"
IE.Document.getElementById("password").Value = "*******"

' Click the "Search" button
IE.Document.getElementByvalue("Signin").onClick

End Sub




I have also attached html code screengrab along with this msg for your reference.

Please assist
Attached Images
File Type: jpg xml code.jpg (75.8 KB, 14 views)
Reply With Quote
  #2  
Old 05-20-2015, 10:54 PM
excelledsoftware excelledsoftware is offline Require assistance in writing code to login to webmail account. Windows 8 Require assistance in writing code to login to webmail account. Office 2003
IT Specialist
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

Here is how I would accomplish it.
Code:
Sub test()
  ' open IE, navigate to the desired page and loop until fully loaded
  Set IE = CreateObject("InternetExplorer.Application")
  my_url = "https://www.google.com"
  
  With IE
    .Visible = True
    .Navigate my_url
    '.Top = 50
    '.Left = 530
    '.Height = 400
    '.Width = 400
    
    Do Until Not IE.Busy And IE.readyState = 4
      DoEvents
    Loop
    
  End With
  
  ' Input the userid and password
  IE.Document.getElementById("username").Value = "*******"
  IE.Document.getElementById("password").Value = "*******"
  
  ' Click the "Search" button
  
  'I find using loops is the best way to accomplish this.  Even though
  'it may run a tiny bit slower it is easiest to debug and do EXACTLY what you want.
  For Each v In IE.Document.GetElementsByTagName("input")
    If v.Value = "Sign in" Then
      v.Click
      Exit For
    End If
  Next v

End Sub
Let me know how that works out for you.

Thanks

Last edited by excelledsoftware; 05-20-2015 at 10:55 PM. Reason: indenting issue
Reply With Quote
  #3  
Old 05-20-2015, 10:57 PM
excelledsoftware excelledsoftware is offline Require assistance in writing code to login to webmail account. Windows 8 Require assistance in writing code to login to webmail account. Office 2003
IT Specialist
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

Normally I would check this to see if it works but since the actual URL was not provided (understandable) I cannot test it. You may need to try GetElementsByClassName but again it can be difficult it if is not an isolated attribute which is why I will loop through the elements and set up as many conditions as I need to ensure I grab the actual value I want.
Reply With Quote
  #4  
Old 05-21-2015, 12:55 AM
saurabhlotankar saurabhlotankar is offline Require assistance in writing code to login to webmail account. Windows XP Require assistance in writing code to login to webmail account. Office 2010 32bit
Novice
Require assistance in writing code to login to webmail account.
 
Join Date: May 2015
Posts: 29
saurabhlotankar is on a distinguished road
Default

Hey, Thanks a ton "excelledsoftware". It is working smoothly. Once again thank you so much for your help.
Reply With Quote
  #5  
Old 05-21-2015, 10:47 AM
excelledsoftware excelledsoftware is offline Require assistance in writing code to login to webmail account. Windows 8 Require assistance in writing code to login to webmail account. Office 2003
IT Specialist
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

You are very welcome
Reply With Quote
Reply

Tags
macro



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Writing VBA Code using the HideMark property bgranzow Word VBA 7 06-02-2014 04:10 PM
Require assistance in writing code to login to webmail account. Assistance require powerpoint presentation wont run? Harold PowerPoint 5 04-18-2013 01:53 AM
Writing code with C# and VB.NET to create Outlook add-ins and other projects kistou Outlook 0 01-13-2010 04:23 AM
Help require. aligahk06 Office 0 08-31-2009 01:30 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:05 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft