Consulting

Results 1 to 11 of 11

Thread: I am trying to call a JavaScript function through VBA - doesn't work

  1. #1
    VBAX Regular
    Joined
    Jul 2015
    Posts
    8
    Location

    I am trying to call a JavaScript function through VBA - doesn't work

    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

  2. #2
    Hi try this..

    IEDoc.parentWindow.execScript "StartBusyBox()"
    Cheers!!!
    A mighty flame followeth a tiny sparkle!!



  3. #3
    VBAX Regular
    Joined
    Jul 2015
    Posts
    8
    Location
    Quote Originally Posted by excelliot View Post
    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

  4. #4
    hello can you share your whole code or url of webpage to which you arevtrying to access..
    A mighty flame followeth a tiny sparkle!!



  5. #5
    VBAX Regular
    Joined
    Jul 2015
    Posts
    8
    Location
    Quote Originally Posted by excelliot View Post
    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:

    pageHtmlGce.jpg


    Thank you

  6. #6
    can't read anything, attach in notepad..
    A mighty flame followeth a tiny sparkle!!



  7. #7
    VBAX Regular
    Joined
    Jul 2015
    Posts
    8
    Location
    imgur.com/KGoKV1T

    Cheers

  8. #8
    it is clear now, can you expand that line & send me code for that...i want to see wahts in that...
    A mighty flame followeth a tiny sparkle!!



  9. #9
    VBAX Regular
    Joined
    Jul 2015
    Posts
    8
    Location
    Sure, I have expanded a few lines:

    imgur.com/nHkWYuM

  10. #10
    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...
    A mighty flame followeth a tiny sparkle!!



  11. #11
    VBAX Regular
    Joined
    Jul 2015
    Posts
    8
    Location
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •