You can call the JavaScript function from VBA using the following:
Call ie.document.parentWindow.execScript("functionName()", "JavaScript")
In your case, it will look like this:
Call ie.document.parentWindow.execScript("var a=function(){javascript:window.open('','ProcStatus','top=50,left=' + (screen.width - 750) + ',width=700,height=500,resizable,status,scrollbars');};var b=function() {if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('MainPage'), {'j_id202:319:j_id208':'j_id202:319:j_id208'},'ProcStatus');}return false};return (a()==false) ? false : b();", "JavaScript")
Alternatively, you can also tell your macro to click the link using the DOM methods. You will have to dig through the source code to find out exactly where the element is located, but in general the code will look like this:
ie.document.getElementsByTagName("a")[3].click
Where 3 is the index of the array of elements "a".
You do not need to know a lot of javascript to be effective in webscraping, but it helps to know some basic DOM methods.
- document.getElementsByTagName - Finds elements with a given tag, such as
table , a , td , tr , div , etc. - document.getElementsByName - Finds elements with the given name
- document.getElementById - Finds elements with the given id
- element.innerText - returns the text of the element
- element.innerHTML - returns the HTML of an element
- element.click - clicks on an element
- element.getAttribute ("attribute") - returns the value of this attribute, for example
href or style
source share