Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. Sub Submit()
  2. Set objIE = CreateObject("InternetExplorer.Application")
  3. objIE.Top = 0
  4. objIE.Left = 0
  5. objIE.Width = 800
  6. objIE.Height = 600
  7. objIE.AddressBar = 0
  8. objIE.StatusBar = 0
  9. objIE.Toolbar = 0
  10. objIE.Visible = True 'We will see the window navigation
  11.  
  12. objIE.Navigate ("http://example.com")
  13.  
  14. Do
  15. DoEvents
  16. Loop Until objIE.ReadyState = 4
  17.  
  18. pageSource = objIE.Document.body.Outerhtml
  19. objIE.Document.GetElementByID("ctl00_ContentPlaceHolder1_txtUserName").Value = "xyz"
  20. objIE.Document.GetElementByID("ctl00_ContentPlaceHolder1_txtPassword").Value = "123"
  21. objIE.Document.GetElementByID("ctl00_ContentPlaceHolder1_btnSubmit1").Click
  22. End Sub
  23.  
  24. +------+---------------+
  25. | User | Password |
  26. +------+---------------+
  27. | ABC | 123 |
  28. | XYZ | 456 |
  29. | XCZ | 777 |
  30. +------+---------------+
  31.  
  32. Sub Submit(User as string, Password as string)
  33. Set objIE = CreateObject("InternetExplorer.Application")
  34. objIE.Top = 0
  35. objIE.Left = 0
  36. objIE.Width = 800
  37. objIE.Height = 600
  38. objIE.AddressBar = 0
  39. objIE.StatusBar = 0
  40. objIE.Toolbar = 0
  41. objIE.Visible = True 'We will see the window navigation
  42.  
  43. objIE.Navigate ("http://example.com")
  44.  
  45. Do
  46. DoEvents
  47. Loop Until objIE.ReadyState = 4
  48.  
  49. pageSource = objIE.Document.body.Outerhtml
  50. objIE.Document.GetElementByID("ctl00_ContentPlaceHolder1_txtUserName").Value = User
  51. objIE.Document.GetElementByID("ctl00_ContentPlaceHolder1_txtPassword").Value = Password
  52. objIE.Document.GetElementByID("ctl00_ContentPlaceHolder1_btnSubmit1").Click
  53. End Sub
  54.  
  55. Sub Login()
  56. dim strUser as string
  57. dim strPassword as string
  58. dim intLastRow as integer
  59. dim intRow as integer
  60.  
  61. intLastRow = Cells(Rows.Count, "A").End(xlUp).Row
  62.  
  63. For intRow = 2 to intLastRow
  64. strUser = Worksheets("MySheet").Cells(intRow, 1).value
  65. strPassword = Worksheets("MySheet").Cells(intRow, 2).value
  66. call Submit(strUser, strPassword)
  67. Next intRow
  68. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement