Be the first user to complete this post
|
Add to List |
VBA-Excel: Login To Already Opened GMAIL In An Internet Explorer (IE)
To Login To Already Opened GMAIL In An Internet Explorer (IE) using Microsoft Excel,
Steps:
- Create the object of Shell Application
- Get all the windows using shellobject.Windows
- Navigate all the windows
- check if window is Internet Explorer
- if window is IE then check if it is Gmail browser and store the object
- Get the Page object of Gmail window.
- Identify the objects on the Page using “GetElementById”
- Set the Authentication details in the Gmail login page
- Identify the Sign In Button using “GetElementById” and Click on it
Create the object of Shell Application
Set objShell = CreateObject("Shell.Application")
Get all the windows using shellobject.Windows
Set objAllWindows = objShell.Windows
Navigate all the windows
For Each ow In objAllWindows
check if window is Internet Explorer
If (InStr(1, ow, "Internet Explorer", vbTextCompare)) Then
if window is IE then check if it is Gmail browser and store the object
If (InStr(1, ow.locationURL, "mail.google.com", vbTextCompare)) Then
Set objGMAIL = ow
End If
Get the Page object of Gmail window.
Set objPage = objGMAIL.Document
Identify the objects on the Page using “GetElementById”
Set NameEditB = objPage.getElementByID(“Email”)
Set the Authentication details in the Gmail login page
NameEditB.Value = strUserName
Identify the Sign In Button using “GetElementById” and Click on it
Set SignIn = objPage.getElementByID(“signIn”)
SignIn.Click
Complete Code:
Sub login() Set objShell = CreateObject("Shell.Application") Set objAllWindows = objShell.Windows For Each ow In objAllWindows 'MsgBox ow If (InStr(1, ow, "Internet Explorer", vbTextCompare)) Then 'MsgBox ow.Hwnd & " " & ow & " " & ow.locationURL If (InStr(1, ow.locationURL, "mail.google.com", vbTextCompare)) Then Set objGMAIL = ow End If End If Next If objGMAIL Is Nothing Then Else Set objPage = objGMAIL.Document Set NameEditB = objPage.getElementByID("Email") NameEditB.Value = "xxxxx" Set PWDEditB = objPage.getElementByID("Passwd") PWDEditB.Value = "yyyyyy" Set SignIn = objPage.getElementByID("signIn") 'SignIn.Click Uncomment it when you put valid gmail credentails End If End Sub
Also Read:
- VBA-Excel: Modified Consolidator – Merge or Combine Multiple Excel Files Into One Where Columns Are Not In Order
- Excel-VBA : Send a Excel Workbook as Attachment in Mail From MS Outlook Using Excel
- VBA-Excel — AttachmentFetcher — Download all the Attachments from All the Mails of Specific Subject in Microsoft Outlook .
- Excel-VBA : Change Passwords for all the WorkSheets in one shot
- VBA-Excel: Create and Save the Word document