Consulting

Results 1 to 1 of 1

Thread: VBA code to click on Image button in IE

  1. #1

    VBA code to click on Image button in IE

    Hi Experts,


    Iam working on a project ''Automation IE'' but got stucked at clicking on Image buttion ...
    Im trying to spool one excel report from website and for the same i need to click on Generate button(type="submit") then one message will appear (Report Spooled Successfully) then only i can click on download button (type="image"). have attached screenshot below for reference



    Screenshot

    Untitled.jpg




    Generate button HTML source code
    HTML Code:
     <td align="right">                <input type="submit" name="ctl00$ContentPlaceHolder1$btnGenerate" value=" Generate " onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ContentPlaceHolder1$btnGenerate&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))"                id="ctl00_ContentPlaceHolder1_btnGenerate" tabindex="4" title="Click Here" class="dxbButton_Glass"></td>



    Below is the HTML source code for message
    HTML Code:
      <td colspan="2">                <span id="ctl00_ContentPlaceHolder1_lblMsg" style="color:Blue;font-weight:bold;">Report Spooled Successfully</span></td>

    Below is The HTML source code for download button (type="image")
    HTML Code:
    <td align="right" visible="false">                click here to Download&nbsp;
    <input type="image" name="ctl00$ContentPlaceHolder1$lnkDownload" id="ctl00_ContentPlaceHolder1_lnkDownload" tabindex="7" title="Download" src="../../Images/save.gif" alt="Download" style="border-width:0px;">            </td>



    With my code i am able to click on Generate button but facing difficulty clicking on Download button after message appeared, have tried to looping until condition is met and tried if Element.innertext = message but no luck.


    Below is the My VBA code




     Sub KBOSS_Brokerage_Process_Status()
    Set Browser = CreateObject("internetexplorer.application")
    Browser.Visible = false
    Browser.navigate ("my url")
    Set mymsg = Browser.document.getElementById("ctl00_ContentPlaceHolder1_lblMsg")
    For Each elem In mymsg.getElementsByTagName("span")
    If elem.innerText = " Report Spooled Successfully " Then Exit For
    Next elem
    Browser.document.getElementById("ctl00_ContentPlaceHolder1_lnkDownload").Click
    Browser.Quit
    Set Browser = Nothing
    End Sub



    Any help greatly appreciated.


    thanks in advance.




    Cross post: https://chandoo.org/forum/threads/vb...7/#post-228291

    https://stackoverflow.com/questions/...e-button-in-ie
    Last edited by Aussiebear; 04-15-2023 at 03:52 AM. Reason: Reduced the whitespace

Posting Permissions

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