Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Submit()
- Set objIE = CreateObject("InternetExplorer.Application")
- objIE.Top = 0
- objIE.Left = 0
- objIE.Width = 800
- objIE.Height = 600
- objIE.AddressBar = 0
- objIE.StatusBar = 0
- objIE.Toolbar = 0
- objIE.Visible = True 'We will see the window navigation
- objIE.Navigate ("http://example.com")
- Do
- DoEvents
- Loop Until objIE.ReadyState = 4
- pageSource = objIE.Document.body.Outerhtml
- objIE.Document.GetElementByID("ctl00_ContentPlaceHolder1_txtUserName").Value = "xyz"
- objIE.Document.GetElementByID("ctl00_ContentPlaceHolder1_txtPassword").Value = "123"
- objIE.Document.GetElementByID("ctl00_ContentPlaceHolder1_btnSubmit1").Click
- End Sub
- +------+---------------+
- | User | Password |
- +------+---------------+
- | ABC | 123 |
- | XYZ | 456 |
- | XCZ | 777 |
- +------+---------------+
- Sub Submit(User as string, Password as string)
- Set objIE = CreateObject("InternetExplorer.Application")
- objIE.Top = 0
- objIE.Left = 0
- objIE.Width = 800
- objIE.Height = 600
- objIE.AddressBar = 0
- objIE.StatusBar = 0
- objIE.Toolbar = 0
- objIE.Visible = True 'We will see the window navigation
- objIE.Navigate ("http://example.com")
- Do
- DoEvents
- Loop Until objIE.ReadyState = 4
- pageSource = objIE.Document.body.Outerhtml
- objIE.Document.GetElementByID("ctl00_ContentPlaceHolder1_txtUserName").Value = User
- objIE.Document.GetElementByID("ctl00_ContentPlaceHolder1_txtPassword").Value = Password
- objIE.Document.GetElementByID("ctl00_ContentPlaceHolder1_btnSubmit1").Click
- End Sub
- Sub Login()
- dim strUser as string
- dim strPassword as string
- dim intLastRow as integer
- dim intRow as integer
- intLastRow = Cells(Rows.Count, "A").End(xlUp).Row
- For intRow = 2 to intLastRow
- strUser = Worksheets("MySheet").Cells(intRow, 1).value
- strPassword = Worksheets("MySheet").Cells(intRow, 2).value
- call Submit(strUser, strPassword)
- Next intRow
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement