View Full Version : I am trying to call a JavaScript function through VBA - doesn't work
nastyJ
07-09-2015, 06:44 AM
Hi all,
I am trying to click on a button present on a webpage using VBA, this button doesn't have any ID:
<a class="homeMenu" onclick="startBusyBox();this.style.cursor='wait' ;document.body.style.cursor='wait' ;" href="/CCCWeb/filterClientListFromDefineAsOf.do?do=clientMenu">
So I am trying to launch the function startBusyBox() like this:
Set IEDoc= IE.document
IEDoc.parentWindow.execScript ("startBusyBox()", "JavaScript")
But it doesn't work:
Run-time error '-2147352319 (800201001)":
Automation error
Anyone has any idea how to solve this??
Thank you very much
excelliot
07-10-2015, 06:55 AM
Hi try this..
IEDoc.parentWindow.execScript "StartBusyBox()"
Cheers!!!
nastyJ
07-10-2015, 07:04 AM
Hi try this..
IEDoc.parentWindow.execScript "StartBusyBox()"
Cheers!!!
Hi Excelliot, thank you for your answer but it's not working though, I have the same automation error
cheers
excelliot
07-10-2015, 08:49 AM
hello can you share your whole code or url of webpage to which you arevtrying to access..
nastyJ
07-13-2015, 02:04 AM
hello can you share your whole code or url of webpage to which you arevtrying to access..
Hello,
The webpage I am trying to access is an intranet page so you won't be able to see it unfortunately. This is the whole code of the page:
13908
Thank you
excelliot
07-13-2015, 03:17 AM
can't read anything, attach in notepad..
nastyJ
07-13-2015, 03:36 AM
imgur.com/KGoKV1T
Cheers
excelliot
07-13-2015, 03:57 AM
it is clear now, can you expand that line & send me code for that...i want to see wahts in that...
nastyJ
07-13-2015, 04:14 AM
Sure, I have expanded a few lines:
imgur.com/nHkWYuM
excelliot
07-13-2015, 06:02 AM
Hi
do you have access to page "WWW/CCCWeb/filterClientListFromDefineAsOf.do?do=clientMenu"
Instead of WWW above add url of intranet on which you are running macro...
nastyJ
07-13-2015, 06:24 AM
Yes I do, and actually I tried this and it worked.
But the issue is that sooner or later I will have to launch a JavaScript fonction. On the page /CCCWeb/filterClientListFromDefineAsOf.do?do=clientMenu, I have a droplist and when I click on it I have another JS function (changeSearchBy() ) as you can see in the screenshot enclosed. So basically almost everytime I want to click on a button or an option, it launches a JS function.
Thanks for your help!
imgur.com/Ml5ARlH
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.