Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
81
rated 0 times [  85] [ 4]  / answers: 1 / hits: 50869  / 14 Years ago, wed, july 14, 2010, 12:00:00

I'm trying to get my VBA routine to interact with a page that uses JavaScript, and have been successful in the past. After a recent update, it no longer works. At this point I need to either A) programmatically click a button or B) execute the function the button calls. The tricky part is that the button has no declared name. There are others on the sheet declared in the source code with names, and I can interact with them just fine. Here's the html code from the page source:



<input type=button class=buttonForm value='Run Report' onclick=exportData(workOrderSearchForm)/>


As you can see, it does not declare a name for the button. In the past, the following has worked:



Set ie = CreateObject(InternetExplorer.application)
ie.document.all(79).Click


With 79 being the index of the item number. It now appears that the button has been changed to item 81, but simply putting in:



ie.document.all(81).Click


is not working for some reason. I know the function I want to execute: exportData(workOrderSearchForm), but don't know how to do so outside of using the click method.



I've looked for some decent documentation regarding the IE application object, but can't seem to find a good source. Is there a way to execute the function?


More From » vba

 Answers
4

Try this:



Dim CurrentWindow As HTMLWindowProxy: Set CurrentWindow = ie.Document.parentWindow
Call CurrentWindow.execScript(exportData(workOrderSearchForm))


But first you will need to include Microsoft HTML Object Library under References (Tools>References)


[#96232] Monday, July 12, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
harleedayanarar

Total Points: 303
Total Questions: 90
Total Answers: 102

Location: Virgin Islands (U.S.)
Member since Tue, Jul 7, 2020
4 Years ago
;