Created
July 31, 2016 17:26
-
-
Save erajanraja24/a6b1704233c8af0b5398835dd4b21af1 to your computer and use it in GitHub Desktop.
Automate Internet Explorer with Excel VBA Part 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Sub automaticformfilling() | |
| Dim ie As Object | |
| Set ie = CreateObject("internetexplorer.application") | |
| With ie | |
| .Visible = True | |
| .navigate "http://newtours.demoaut.com/mercuryregister.php" | |
| 'Wait for loading | |
| Do While .busy | |
| DoEvents | |
| Loop | |
| Do While .readystate <> 4 | |
| DoEvents | |
| Loop | |
| End With | |
| Set fname = ie.document.getelementbyid("firstName") | |
| fname.Value = "First Name" | |
| Set lastName = ie.document.getelementbyid("lastName") | |
| lastName.Value = "Last Name" | |
| Set phone = ie.document.getelementbyid("phone") | |
| phone.Value = "54646346" | |
| Set UserName = ie.document.getelementbyid("userName") | |
| UserName.Value = "[email protected]" | |
| Set address1 = ie.document.getelementbyid("address1") | |
| address1.Value = "Add 1" | |
| Set address2 = ie.document.getelementbyid("address2") | |
| address2.Value = "Add 2" | |
| Set city = ie.document.getelementbyid("city") | |
| city.Value = "Tim" | |
| Set State = ie.document.getelementbyid("state") | |
| State.Value = "Iowa" | |
| Set postalCode = ie.document.getelementbyid("postalCode") | |
| postalCode.Value = "45345" | |
| Set country = ie.document.getelementbyid("country") | |
| For i = 1 To country.Options.Length | |
| If country.Options(i).Text = "INDIA" Then | |
| country.selectedindex = i | |
| Exit For | |
| End If | |
| Next i | |
| Set Email = ie.document.getelementbyid("email") | |
| Email.Value = "[email protected]" | |
| Set Password = ie.document.getelementbyid("password") | |
| Password.Value = "pwd@123" | |
| Set confirmPassword = ie.document.getelementbyid("confirmPassword") | |
| confirmPassword.Value = "pwd@123" | |
| ie.document.forms(0).submit | |
| End Sub | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ODaddy63
Maybe it can help you.