View Full Version : [SOLVED:] Call a javascript function
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
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?
stanl
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
.Document.GetElementsByTagName("TAG").Item(n).FireEvent("click()")
which would then run the jscript.
.02 Stan
stanl,
I had already tried it but it didn't work.
stanl
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")
this way it works
IE.document.all.Item
Call IE.document.parentWindow.execScript("buttonMovimenti()", "JavaScript")
stanl
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?
Stan
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.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.