View Full Version : Solved: call a javascript function

09-29-2006, 05:49 AM
Hi everybody.

I'm working with excel vba over a web page. This page has a Javascript function "ButtonMovimenti()".

Is there a way to call that function from vba (I'm using the reference to Internet Explorer).

Thanks in advance

09-29-2006, 06:45 AM
Well I solved it in a way but I still have some problem.

With this line the function is called:
Call IE.document.parentWindow.execScript("buttonMovimenti()", "JavaScript")

the fact is that I get the result page without problem only if at least one item of the webpage is selected or has focus.
If no item has focus or selected than I'm sent to an error page.

you know why?

09-30-2006, 08:16 AM
I don't know the 'why' as there is not enough information provided to even make a S.W.A.G. - but assuming the jscript function can be normally called within the DHTML, say by clicking a button or another object you can always use something like


which would then run the jscript.
.02 Stan

10-02-2006, 12:46 AM

I had already tried it but it didn't work.

10-02-2006, 04:48 AM
Hmmm. then perhaps something like (where myElement is a named element on the HTML page

Call IE.document.parentWindow.execScript("document.all.myElement.focus();buttonMovimenti();", "JavaScript")

10-02-2006, 05:08 AM
this way it works
Call IE.document.parentWindow.execScript("buttonMovimenti()", "JavaScript")

10-02-2006, 11:22 AM
Great!:clap: I was a little confused by the need to use 'Call' and not execute the script directly. I have used execscript() sparingly for dynamic DHTML mostly because it lacks error handling.

I am still curious as to whether the jscript code is callable from within the page?


10-03-2006, 12:13 AM
stanl, as you'll have noticed I'm not an expert of javascript/html.

So I see my solution works but I don't know actually what's the point.

02-27-2014, 02:26 AM
Can javaScript create rich interactivity? Can JavaScript create a rich interactive site like animations that when rolled over play out, or an interactive object that can be drug around the screen like a type of video game of sorts? or is Javascript limited to just hover buttons and photo gallery's thing like that?