Login Automatically into Social Media Networks in IE using Excel
These days’ people spend too much time in Social Media Networks like Facebook, Twitter, and Google+. We tend to Login and Logout so frequently into these accounts. Sometimes we get tired mentally, typing these Login IDs and Passwords either because it is too lengthy or we logout/log in often. We can bypass that tiny boring moment ,of re-typing the login credentials again and again, by automating the steps with the help of Excel Macro.Login Form & Common Fields
When we type the URL of FB, Twitter or any kind of Webpage that has a Login Form, It will have these fields.- Login ID or Email ID or Mobile Number
- Password
- Submit button
Auto Fill Form and Click Submit Button
With the below code snippet we will be able to fill a Login form in Facebook. The same code can be used to auto fill Twitter, Google+ or any HTML form. All you need to do is to analyze the HTML Source code before automating the login process. Lets see how to do this for Facebook and then discuss more on other forms. Copy this code, Paste it in Excel VB Editor and Execute by Pressing F5.Private Sub Facebook_Login_Automate()
'Declare Variables used in Code
Dim InetApp As Object
Dim TagsArray As Object
Dim TagField As Object
'Create InternetExplorer Object and Launch App
Set InetApp = CreateObject("InternetExplorer.Application")
InetApp.Visible = True
'Navigate to Facebook
InetApp.Navigate "http://www.facebook.com/"
'Internet Explorer Load Time Wait
Do While InetApp.Busy
Application.StatusBar = "Application Loading. Please Wait..."
Application.Wait DateAdd("s", 1, Now)
Loop
Application.StatusBar = ""
'HTML code is obtained from URL.
'Search for tag <input> and store it details in a object.
Set TagsArray = InetApp.document.getElementsByTagName("input")
idx = 0
'Search Fields Corresponding to 'Login id', 'Password' and 'Submit' button.
While idx < TagsArray.Length
If TagsArray(idx).Name = "email" Then
TagsArray(idx).Value = "FB_Login_Mail_ID@mail.com"
Else
If TagsArray(idx).Name = "pass" Then
TagsArray(idx).Value = "FB_Login_Password"
End If
If TagsArray(idx).Type = "submit" And _
TagsArray(idx).Name = "" Then
Set TagField = TagsArray(idx)
End If
End If
idx = idx + 1
Wend
'Click Submit Button
TagField.Click
'Login Wait Time
Do While InetApp.Busy
Application.StatusBar = "Login in Progess. Please Wait..."
Application.Wait DateAdd("s", 1, Now)
Loop
Application.StatusBar = ""
InetApp.Visible = True
'Clear Object Data
Set InetApp = Nothing
Set TagField = Nothing
Set TagsArray = Nothing
End Sub
This code actually gets the HTML source for a form. Then search for the Login and Password text fields and substitute a value for them. Once this is done, it auto click the 'Submit' button.
All you need to do is to just run the macro with a button click and wait for the code to throw your Facebook wall.
To use the same technique with Twitter or Google+, search or inspect the Tag and Field names used in Login Form and substitute them in the above code.
Important Note:
The code will have password stored in it. So, protect the VBA project with a strong password and also store the Excel document in a secure way. Else, you Social Media Login Credentials will be compromised.
More Tips: Simplest Method to Password Protect MS Office Documents