vba to click webpage button with onmouseover and inside a frame

  • Hi,


    I´m trying to access a table in a webpage. I´ve managed to log in with username and password and several navigation steps, mainly using Document.getElementById and .click for buttons and parentWindow.execScript when the button was associated with a script. I got to a point where I´m definitely struck . I got to a page where none of the getElement works to find the reference to the button I want and besides that the button works in different way : there is an onmouseover tag associated with a script of some kind.
    I tried to use getElement to an inner frame where the tag should be found with no success.





    Here´s the code I have so far :





    And here is some of the HTML code related to the page I´m stuck :
    The “button” I want to activate is inside this frame “main” :

    HTML
    <frame name="main" src="painel_controle.asp" marginwidth="0" marginheight="0" target="main">
                    <title>Menu Documentos</title>
    <link href="estilo/estilo.css" rel="stylesheet" type="text/css">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <base target="main">
    <script language="Javascript">

    And this is the “button” :

    HTML
    <a href="aviso/documentos_menu_aviso.asp"><img width="155" height="23" id="IMG2" onmouseover="muda(this,'images/aviso_credito_on.gif')" onmouseout="muda(this,'images/aviso_credito_off.gif')" src="images/aviso_credito_off.gif" border="0"></a>
    <img width="155" height="23" id="IMG2" onmouseover="muda(this,'images/aviso_credito_on.gif')" onmouseout="muda(this,'images/aviso_credito_off.gif')" src="images/aviso_credito_off.gif" border="0">



    Any help would be greatly appreciated.

    Thanks

  • Re: vba to click webpage button with onmouseover and inside a frame


    Try something like this:

    That's all I can suggest without accessing the page and any other help would be guessing. You need to set an additional reference to MS HTML Object Library, otherwise the code won't compile or run.


    PS - as you can see from your code, this forum doesn't like multiple statements on the same line, separated by the ":" character; you have to put the Do Loop statements on separate lines for the forum indentation to work.

  • Re: vba to click webpage button with onmouseover and inside a frame


    If possible, I suggest you use helper software like iMacros (imacros.net) I've experienced the same issue you have many times with hard to grab tags or tags that keep changing. Imacros allow you to open page in your browser, click on buttons, fill out forms, copy tables etc and it grabs/translates all the HTML tags for you. It's like using excel's macro recorder feature but in a browser. Once you have your imacros recorded, you can call them with a simple VBA script. They have literally saved me 100's of hours of coding. good luck

  • Re: vba to click webpage button with onmouseover and inside a frame


    Thanks guys!


    Your code worked perfectly John, thank you very much and sorry for the formatting problem.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!