Guest User

Untitled

a guest
Jun 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. Option Explicit
  2. Sub SaveHTml()
  3. Dim str1, str2, str3, str4, str5, str6, str7, URL As String
  4. Dim ie, frm As Object
  5. Dim i As Long
  6. Dim filename As String
  7. Dim FF As Integer
  8. 'Dim elems As IHTMLInputTextElement
  9. Dim wb As WebBrowser
  10. Dim objElement As Object
  11. Dim objCollection As Object
  12. Dim Button As Object
  13.  
  14. 'On Error Resume Next
  15. Application.ScreenUpdating = False
  16. str1 = Sheets("PR_data_with_search").Range("F10").Value
  17. str2 = Sheets("PR_data_with_search").Range("I10").Value
  18.  
  19. URL = "https://webtac.industrysoftware.automation.com/webpr/webpr.php?objtype=frames" 'for TEST
  20. filename = "C:Users" & Environ("UserName") & "DesktopTest.htm"
  21.  
  22. Set ie = CreateObject("Internetexplorer.Application")
  23. ie.Visible = True
  24. ie.Navigate URL
  25.  
  26. Do Until ie.ReadyState = 4
  27. DoEvents
  28. Loop
  29.  
  30. Set ie = Nothing
  31. ' load next web page
  32. Dim i1 As Integer
  33. Dim txt, p As String, link As String
  34. txt = "Advanced Search"
  35. Do Until link = txt
  36. i1 = i1 + 1
  37. p = ie.Document.Links(i1).tostring
  38. link = Right(p, 6)
  39. Loop
  40. ie.Document.Links(i).Click
  41.  
  42. ie.Document.getelementsbyname("openedFrom_dateText")(0).Value = str1
  43. ie.Document.getelementsbyname("openedTo_dateText")(0).Value = str2
  44.  
  45. 'Call ie.Document.getElementsByTagName("ok").Item(1).Click
  46. Set Button = ie.Document.getElementById("ok")
  47. Button.Click
  48.  
  49. Do
  50. Loop While ie.Busy
  51.  
  52. CreateObject("Scripting.FileSystemObject").CreateTextFile filename
  53.  
  54. Do Until ie.ReadyState = 4
  55. DoEvents
  56. Loop
  57.  
  58. FF = FreeFile
  59. Open filename For Output As #FF
  60.  
  61. With ie.Document.body
  62. Print #FF, .outerHTML & .innerHTML
  63. End With
  64.  
  65. Close #FF
  66.  
  67. ie.Quit
  68. Set ie = Nothing
  69. Application.ScreenUpdating = True
  70. End Sub
  71.  
  72. <li><a href="javascript:parent.gotoSearch('advanced')">Advanced Search</a></li>
  73.  
  74. <input type=button name="ok" id="ok" value=" OK " onClick="onSubmitFunction()">
  75.  
  76. ie.document.querySelector("a[href='javascript:parent.gotoSearch('advanced')']").Click
  77.  
  78. While IE.Busy Or IE.readyState < 4: DoEvents: Wend
  79. Application.Wait Now + TimeSerial(0,0,2) '<== uncomment this for additional wait time. Change 2 to other # of seconds as required.
  80.  
  81. ie.document.getElementById("ok").Click
  82.  
  83. Do
  84. DoEvents
  85. Dim a As Object
  86. On Error Resume Next
  87. Set a = IE.document.getElementById("ok")
  88. On Error GoTo 0
  89. Loop While a Is Nothing
Add Comment
Please, Sign In to add comment