code_junkie

How to call a javascript file (.js) via Excel VBA?

Nov 12th, 2011
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. Set maPageHtml = IE.document
  2. Set Helem = maPageHtml.getElementsByTagName("input")
  3.  
  4. For i = 0 To Helem.Length - 1
  5. If Helem(i).getAttribute("name") = "toFind" Then Helem(i).Value = "819971" '819971 is the valeo reference searched
  6. If Helem(i).getAttribute("name") = "submit" Then Set Monbouton = Helem(i)
  7. Next
  8.  
  9. Monbouton.Click 'this does the click on my button Monbouton
  10.  
  11. oIE.Document.frmMain.param1.Value = 5
  12. oIE.Document.frmMain.param2.Value = "6"
  13. oIE.Document.frmMain.submit.click ' this line will call the JavaScript function
  14.  
  15. <div id="submit" > <a href="javascript:doAction();">Do Action</a></div>
  16.  
  17. <script>
  18. function doAction()
  19. {
  20. // do whatever the code should do
  21. }
  22. </script>
Add Comment
Please, Sign In to add comment