Results 1 to 10 of 10

Thread: Unable to Get ElementID In VBA IE Automation

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    20
    Rep Power
    0

    Unable to Get ElementID In VBA IE Automation

    Hi
    i am really stuck bad in ie automation where m not able to select an combobox option with the element id can any one help.

    i have puted the html code i got from the web page please help me on this.

    Code:
    <td class="formtext1" valign="top">
                                                                        Select Workgroup
                                                                    </td>
                                                                    <td class="formtext1">
                                                                    <select name="WorkGroup" onchange="javascript:setTimeout('__doPostBack(\'WorkGroup\',\'\')', 0)" id="WorkGroup" class="inputbox10px" DesignTimeID="WorkGroup" style="width:200px;width:160px;">
    	<option selected="selected" value="-1">Select</option>
    	<option value="0">All</option>
    	<option value="231">AIU - AP Invoice related queries - UK</option>
    	<option value="218">APA - AP Urgent Payments - AUS</option>
    	<option value="225">APC - AP related queries - Singapore</option>
    	<option value="224">APE - AP related queries - Philippines</option>
    	<option value="207">API - AP Invoices</option>
    	<option value="228">APM - AP related queries - Malaysia</option>
    	<option value="208">APN - AP New supplier creation - UK</option>
    	<option value="210">APP - AP Urgent Registrations - UK</option>
    	<option value="219">APQ - AP related queries - AUS</option>
    	<option value="206">APR - AP related queries - India</option>
    	<option value="220">APS - AP New supplier creation - AUS</option>
    	<option value="209">APU - AP Urgent Payments - UK</option>
    	<option value="212">ARC - AR Credit related queries - UK</option>
    	<option value="229">ARM - AR related queries - Malaysia</option>
    	<option value="204">ARR - AR related queries - India</option>
    	<option value="226">ARS - AR related queries - Singapore</option>
    	<option value="221">GII - General inquiries for Ireland</option>
    	<option value="211">IRQ - Intercompany related queries - UK</option>
    	<option value="217">RRT - RTR Treasury- UK</option>
    	<option value="222">RTL - RTR label - UK</option>
    	<option value="230">RTM - RTR queries - Malaysia</option>
    	<option value="223">RTQ - RTR queries - Philippines</option>
    	<option value="205">RTR - RTR queries - India</option>
    	<option value="227">RTS - RTR queries - Singapore</option>
    	<option value="213">RTT - RTR Treasury related queries -  UK</option>
    	<option value="216">RTU - RTR UMOsupport- UK</option>

  2. #2
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    It's hard to say from the source code. Post the URL, and indicate which element it is.
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  3. #3
    Junior Member
    Join Date
    Mar 2013
    Posts
    20
    Rep Power
    0
    Hi thanks for the reply as its a company link it wont work on your pc as i have attached a image of it and posted the whole source code please if you can provide me the code to click the cutton which is circuled and to change the combobox details will really help..
    thanks in advance
    web page.JPG
    Code:
    
    <html>
    <head id="Head1"><title>
    
    </title><link href="../Css/loanservicing.css" rel="stylesheet" type="text/css" />
        <script language="javascript" src="../Js/validation.js" type="text/javascript">
        </script>
        <script language="javascript" type="text/javascript">
                 parent.SetFrameHeight()
            function ExportToExcel()
            {
                window.open('TaskDataExtractionExcel.aspx','EscrowAdmin','');
                return false;
            }
                    function CheckLoanID()
                    {
    	                if(isNaN(parseFloat(document.getElementById(GetClientID("Loan")).value)))
    		                document.getElementById(GetClientID("Loan")).value='';
                    }
    
        </script>
    </head>
    <body  onkeypress='return disableEnter();' onbeforeunload="AskSave(document.forms['Form1']);"><div style='POSITION: absolute; top:200;left:450;'><img src='/UMGMUMBAI/Images/preloader.gif' id='__Page_ProcessingImage' style='display:none' /></div><form name="Form1" method="post" action="TaskDataExtraction.aspx?mnuOpt=8%7c223&amp;OtherMenu=true" onsubmit="javascript:return WebForm_OnSubmit();" id="Form1" AutoComplete="off">
    <div>
    <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
    <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
    <input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value="" />
    <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTQ2ODM2NTc0Mw8WAh4IUGFnZVNpemUCFBYCAgMPFgIeDEF1dG9Db21wbGV0ZQUDb2ZmFlxmDxYCHgxEZXNpZ25UaW1lSUQFEmhkbkxhc3RGb2N1c0N0cmxJRGQCAQ9kFgJmD2QWAmYPZBYCZg9kFgJmD2QWBGYPFgIfAgULaGRuQ2FsbGVkYnlkAgIPFgIfAgUMVGFibGVTdWJNZW51FgJmD2QWAmYPZBYCZg9kFgJmD2QWJGYPFgIfAgUUQ2FzZURpc3RyaWJ1dGlvbl8yMTkWAmYPD2QWAh8CBQRhMjE5ZAIBDxYCHwIFB1NlcF8yMjBkAgIPFgIfAgUOVG90YWxDYXNlc18yMjAWAmYPD2QWAh8CBQRhMjIwZAIDDxYCHwIFB1NlcF8yMjFkAgQPFgIfAgUQUHJvZHVjdGl2aXR5XzIyMRYCZg8PZBYCHwIFBGEyMjFkAgUPFgIfAgUHU2VwXzIxMWQCBg8WAh8CBRJBbGxvY2F0aW9uR3JpZF8yMTEWAmYPD2QWAh8CBQRhMjExZAIHDxYCHwIFB1NlcF8yMTJkAggPFgIfAgULRHVlRGF0ZV8yMTIWAmYPD2QWAh8CBQRhMjEyZAIJDxYCHwIFB1NlcF8yMjJkAgoPFgIfAgUXUmVzb3VyY2VVdGlsaXphdGlvbl8yMjIWAmYPD2QWAh8CBQRhMjIyZAILDxYCHwIFB1NlcF8yMjNkAgwPFgIfAgUSRGF0YUV4dHJhY3Rpb25fMjIzFgJmDw9kFgIfAgUEczIyM2QCDQ8WAh8CBQdTZXBfMjI2ZAIODxYCHwIFDVNMQVJlcG9ydF8yMjYWAmYPD2QWAh8CBQRhMjI2ZAIPDxYCHwIFB1NlcF8yMjdkAhAPFgIfAgUSUmVjb25jaWxsYXRpb25fMjI3FgJmDw9kFgIfAgUEYTIyN2QCEQ9kFgJmD2QWAmYP</div>
    
    <script type="text/javascript">
    //<![CDATA[
    var theForm = document.forms['Form1'];
    if (!theForm) {
        theForm = document.Form1;
    }
    function __doPostBack(eventTarget, eventArgument) {
        if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
            theForm.__EVENTTARGET.value = eventTarget;
            theForm.__EVENTARGUMENT.value = eventArgument;
            theForm.submit();
        }
    }
    //]]>
    </script>
    <script src="/UMGMUMBAI/WebResource.axd?d=0OEOIgTBPMMWr1XWhIR5pShQLVXCnDYKXzERNKpRH4mVXeH0kM2_SEP1j0DPIyRKYfQDYod9y7YncEuMqCNQ23nL00w1&amp;t=634208976757546466" type="text/javascript"></script>
    <script language="javascript" src="/UMGMUMBAI/JS/Toolbar.js"></script>
    <script src="/UMGMUMBAI/WebResource.axd?d=kV4Gkml1UPXr-uV0NUhwcs7E54d-IEwsPcrY_69bJKwjpt7dC37tifA4Fv-qfs_dFeU8AM2kSYCtk1p4SlgCYZ7mffs1&amp;t=634208976757546466" type="text/javascript"></script>
    <script type="text/javascript">
    //<![CDATA[
    function WebForm_OnSubmit() {
    if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
    return true;
    }
    //]]>
    </script>
    
    <div>
    
    	<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWegLn2MRNAseJ+uEKAoDg47QHAsKF0NgIAtKKoeMDAtHlx44PAsLli40PApGdvqwGAoLuu/MJAv22u8cNAsbZ3e0HAreE/60BAoLut/MJAoLuv/MJAvqkqNkIArnHmcYHApiv4doLAvqkpNkIArnHncYHAoyK5IcMArnHlcYHAsbZpewHApivmdoLApGdgqwGApGdhqwGAreE+60BAoyK4IcMAvqkoNkIAqvj/5oKAv22g8cNAreE960BAqvjw5oKApivndoLApHUhrMPAtPe9+gOAu/+v90MArSntucKAob1jLgKAsCA944IArGdp8wDAojcsPgLAq21oLoEArK1oLoEArO1oLoEArC1oLoEArG1oLoEAra1oLoEAre1oLoEAu+ekuQKArOcno8BArnikO0PArzB8vwJArPSr8ENAp3RmdUJAuSJu6cKAoS+srcCAp+x3YkGApuQvpUCAornkLELAsP0pT4Cvqba2AgC47/51QwC0fLM1QICzbz+iQsC7aayjwsC44m95gYCvrTp1wcCxPubuw0Cydvn+w4C3Z2F+gICsKyyBgLb5roBAryB4+8PAsyu3OcBArap84ICArnpuYgHAqjVko0PArvXjoUKApW0rO8CAtWI2okIAuO64OUFAu6piQ0Ct9yW0wMCjJT63gsC0JP1vw0C+5KFogcCnazAqA8C6+zfuQ8CyIffjwwC0dWWuwYCy9fD1wcCge7o/A0C3KKQnAQC/7Px4A4C4rOV4w4C4rON4w4C5rOF4w4C4rOB4w4Clr30kA8CkdrW6AwC7ZrH+QcC6fKGtwkC4oaLrgsCjvquowcCn9TO3Q8C4tmC5w8Ct/PtTwLklN+BBwLz8uubAgLr24L6DgKbvdTsDAKF7+a8CgLW66H0DwLsyuLvCQLQ4L+dAQLjhJP1AwKi7t/1DALv6YbdBALh++WiCAL1qJyMDAKn2pL8CQKjm5WMBrFvsXr4vnRg+InaKxYtpyDgWPJ6" />
    </div><input name="hdnLastFocusCtrlID" type="hidden" id="hdnLastFocusCtrlID" DesignTimeID="hdnLastFocusCtrlID" /><table cellspacing="0" cellpadding="0" border="0" style="width:100%;border-collapse:collapse;">
    	<tr>
    		<td><input name="OtherLevelMenu$hdnCalledby" type="hidden" id="OtherLevelMenu_hdnCalledby" DesignTimeID="hdnCalledby" />
        <script language="javascript" type="text/javascript">
        function LoanBoardKeyPress(ctrl)
        {
            if(window.event.keyCode==13)
            {
                event.keyCode=0;
                ev = document.getElementById(ctrl.id).onmouseup;
                if(typeof(ev) == "function" )
                {
                    return document.getElementById(ctrl.id).onmouseup();
                }
                document.getElementById(ctrl.id).onclick();
            }
        }
        </script>
    <table id="OtherLevelMenu_TableSubMenu" cellpadding="0" border="0" cellspacing="0" style="width:100%;height:100%;" DesignTimeID="TableSubMenu">
    			<tr>
    				<td><table cellpadding="0" cellspacing="0" border="0" width="100%">
    					<tr>
    <td id="OtherLevelMenu_CaseDistribution_219" nowrap="true" class="sub_grey_black" DesignTimeID="CaseDistribution_219"><a id="OtherLevelMenu_a219" class="blacklink" href="#" onclick="return parent.SetLink('Reports/CaseDistributionRpt.aspx?mnuOpt=8|219&amp;OtherMenu=true')" onkeypress="LoanBoardKeyPress(this)" DesignTimeID="a219"><span>Case Distribution</span></a></td>
    <td id="OtherLevelMenu_Sep_220" nowrap="true" class="sub_grey_black" DesignTimeID="Sep_220"><span>|</span></td>
    <td id="OtherLevelMenu_TotalCases_220" nowrap="true" class="sub_grey_black" DesignTimeID="TotalCases_220"><a id="OtherLevelMenu_a220" class="blacklink" href="#" onclick="return parent.SetLink('Reports/TotalCasesRpt.aspx?mnuOpt=8|220&amp;OtherMenu=true')" onkeypress="LoanBoardKeyPress(this)" DesignTimeID="a220"><span>Total Cases</span></a></td>
    						<td id="OtherLevelMenu_Sep_221" nowrap="true" class="sub_grey_black" DesignTimeID="Sep_221"><span>|</span></td>
    						<td id="OtherLevelMenu_Productivity_221" nowrap="true" class="sub_grey_black" DesignTimeID="Productivity_221"><a id="OtherLevelMenu_a221" class="blacklink" href="#" onclick="return parent.SetLink('Reports/ProductivityRpt.aspx?mnuOpt=8|221&amp;OtherMenu=true')" onkeypress="LoanBoardKeyPress(this)" DesignTimeID="a221"><span>Productivity</span></a></td>
    						<td id="OtherLevelMenu_Sep_211" nowrap="true" class="sub_grey_black" DesignTimeID="Sep_211"><span>|</span></td>
    						<td id="OtherLevelMenu_AllocationGrid_211" nowrap="true" class="sub_grey_black" DesignTimeID="AllocationGrid_211"><a id="OtherLevelMenu_a211" class="blacklink" href="#" onclick="return parent.SetLink('Reports/AllocationGridReport.aspx?mnuOpt=8|211&amp;OtherMenu=true')" onkeypress="LoanBoardKeyPress(this)" DesignTimeID="a211"><span>Allocation Grid</span></a></td>
    						<td id="OtherLevelMenu_Sep_212" nowrap="true" class="sub_grey_black" DesignTimeID="Sep_212"><span>|</span></td>
    						<td id="OtherLevelMenu_DueDate_212" nowrap="true" class="sub_grey_black" DesignTimeID="DueDate_212"><a id="OtherLevelMenu_a212" class="blacklink" href="#" onclick="return parent.SetLink('Reports/DueDateRpt.aspx?mnuOpt=8|212&amp;OtherMenu=true')" onkeypress="LoanBoardKeyPress(this)" DesignTimeID="a212"><span>Due Date</span></a></td>
    						<td id="OtherLevelMenu_Sep_222" nowrap="true" class="sub_grey_black" DesignTimeID="Sep_222"><span>|</span></td>
    						<td id="OtherLevelMenu_ResourceUtilization_222" nowrap="true" class="sub_grey_black" DesignTimeID="ResourceUtilization_222"><a id="OtherLevelMenu_a222" class="blacklink" href="#" onclick="return parent.SetLink('Reports/DailyUtilization.aspx?mnuOpt=8|222|10&amp;OtherMenu=true')" onkeypress="LoanBoardKeyPress(this)" DesignTimeID="a222"><span>Resource Utilization</span></a></td>
    						<td id="OtherLevelMenu_Sep_223" nowrap="true" class="sub_grey_black" DesignTimeID="Sep_223"><span>|</span></td>
    						<td id="OtherLevelMenu_DataExtraction_223" nowrap="true" class="sub_grey_black" style="color:#6D0202;" DesignTimeID="DataExtraction_223"><span id="OtherLevelMenu_s223" DesignTimeID="s223">Data Extraction</span></td>
    						<td id="OtherLevelMenu_Sep_226" nowrap="true" class="sub_grey_black" DesignTimeID="Sep_226"><span>|</span></td>
    						<td id="OtherLevelMenu_SLAReport_226" nowrap="true" class="sub_grey_black" DesignTimeID="SLAReport_226"><a id="OtherLevelMenu_a226" class="blacklink" href="#" onclick="return parent.SetLink('Reports/SLAReport.aspx?mnuOpt=8|226&amp;OtherMenu=true')" onkeypress="LoanBoardKeyPress(this)" DesignTimeID="a226"><span>SLA Report</span></a></td>
    						<td id="OtherLevelMenu_Sep_227" nowrap="true" class="sub_grey_black" DesignTimeID="Sep_227"><span>|</span></td>
    						<td id="OtherLevelMenu_Reconcillation_227" nowrap="true" class="sub_grey_black" DesignTimeID="Reconcillation_227"><a id="OtherLevelMenu_a227" class="blacklink" href="#" onclick="return parent.SetLink('Reports/ReconciliationReport.aspx?mnuOpt=8|227&amp;OtherMenu=true')" onkeypress="LoanBoardKeyPress(this)" DesignTimeID="a227"><span>Reconcillation</span></a></td>
    						<td width="100%" nowrap="true" align="right" class="sub_grey_black" style="color:#6D0202;">
    
    
      <script language="javascript" type="text/javascript">
        var timeOut;
        function QuickSearchKeyPress()
        {
            if(window.event.keyCode==13)
            {
                event.keyCode=0;
                CheckSearch();
                if ((document.getElementById('SearchGo') != null ) && (typeof(document.getElementById('SearchGo')) != 'undefined'))
                {
                    ev = document.getElementById('SearchGo').onmouseup;
                    if(typeof(ev) == "function" )
                    {
       			        ev = ev.toString();
                        if(ev.indexOf("askSave")>0)
                        { 
                            try
                     
        </table>
    
    						</div></td>
    						<td width="100%" align="right" class="sub_grey_black"></td>
    	                                                <tr>
                                                        <td colspan="2" class="light_yellow" valign="top" style="padding-bottom: 6px">
                                                            <table width="100%" border="0" cellspacing="0" cellpadding="2">
                                                              
                                                                <tr>
                                                                    <td colspan="2" class="formtext1_bold">Build Filter</td>
                                                                </tr>
                                                              
                                                                <tr>
                                                                    <td class="formtext1" valign="top">
                                                                        Select Workgroup
                                                                    </td>
                                                                    <td class="formtext1">
                                                                    <select name="WorkGroup" onchange="javascript:setTimeout('__doPostBack(\'WorkGroup\',\'\')', 0)" id="WorkGroup" class="inputbox10px" DesignTimeID="WorkGroup" style="width:200px;width:160px;">
    	<option selected="selected" value="-1">Select</option>
    	<option value="0">All</option>
    	<option value="231">AIU - AP Invoice related queries - UK</option>
    	<option value="218">APA - AP Urgent Payments - AUS</option>
    	<option value="225">APC - AP related queries - Singapore</option>
    	<option value="224">APE - AP related queries - Philippines</option>
    	<option value="207">API - AP Invoices</option>
    	<option value="228">APM - AP related queries - Malaysia</option>
    	<option value="208">APN - AP New supplier creation - UK</option>
    	<option value="210">APP - AP Urgent Registrations - UK</option>
    	<option value="219">APQ - AP related queries - AUS</option>
    	<option value="206">APR - AP related queries - India</option>
    	<option value="220">APS - AP New supplier creation - AUS</option>
    	<option value="209">APU - AP Urgent Payments - UK</option>
    	<option value="212">ARC - AR Credit related queries - UK</option>
    	<option value="229">ARM - AR related queries - Malaysia</option>
    	<option value="204">ARR - AR related queries - India</option>
    	<option value="226">ARS - AR related queries - Singapore</option>
    	<option value="221">GII - General inquiries for Ireland</option>
    	<option value="211">IRQ - Intercompany related queries - UK</option>
    	<option value="217">RRT - RTR Treasury- UK</option>
    	<option value="222">RTL - RTR label - UK</option>
    	<option value="230">RTM - RTR queries - Malaysia</option>
    	<option value="223">RTQ - RTR queries - Philippines</option>
    	<option value="205">RTR - RTR queries - India</option>
    	<option value="227">RTS - RTR queries - Singapore</option>
    	<option value="213">RTT - RTR Treasury related queries -  UK</option>
    	<option value="216">RTU - RTR UMOsupport- UK</option>
    
    </select>
                                                                    <span id="ValidateWorkgroup" class="ErrorCross" DesignTimeID="ValidateWorkgroup" style="color:Red;visibility:hidden;">r</span>
                                                                     </td>
                                                                </tr>

  4. #4
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Again, can't be sure which hierarchy the element is part of. So try finding out the classname or the ID of the element using the code below

    Code:
        Dim ie As InternetExplorer
        Dim obj As HTMLObjectElement
        Dim doc As HTMLDocument
        
        Set ie = New InternetExplorer
        ie.navigate "http://www.excelfox.com/forum/f13/replace-incorrect-date-cell-another-valid-date-854/"
        ie.Visible = True
        Do While ie.Busy: Loop
        Do While ie.readyState <> READYSTATE_COMPLETE: Loop
        Set doc = ie.document
        For Each obj In doc.all
            If obj.textContent = "Select" Then
                MsgBox obj.ID
                MsgBox obj.className
                Exit For
            End If
        Next obj
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  5. #5
    Junior Member
    Join Date
    Mar 2013
    Posts
    20
    Rep Power
    0
    Hi Fox tried the code but it says object doesnt support the property or method wherein i tried with the innertext but didn't worked.
    as its in a frame on a table does firstly i have to get the frame and the table id to make it work please suggest

  6. #6
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    I suggest you put a break during code execution, and manually select the control, and then try to figure the ID of the activeElement

    Code:
        Dim ie As InternetExplorer    Dim obj As HTMLObjectElement
        Dim doc As HTMLDocument
        
        Set ie = New InternetExplorer
        ie.navigate "http://www.excelfox.com/forum/f2/unable-get-elementid-vba-ie-automation-851/"
        ie.Visible = True
        Do While ie.Busy: Loop
        Do While ie.readyState <> READYSTATE_COMPLETE: Loop
        Stop ' Now tab-activate the control, and come to this code again and push F8
        Set doc = ie.document
        MsgBox doc.activeElement.ID
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  7. #7
    Junior Member
    Join Date
    Mar 2013
    Posts
    20
    Rep Power
    0
    Mr fox i got the code running for taking element id from frame and tabels but when clicking the button throught element id code runs but does not click on the button on ie below is the code which i used

    please reply quick as need to work more on the project.

    Thanks in advance.

    Code:
    Dim myHTMLDoc As HTMLDocument
        Set myHTMLDoc = ie.document
     
        'set myHTMLFrame2 as the 2nd frame of the main page (index starts at 0)
        Dim myHTMLFrame2 As HTMLDocument
        Set myHTMLFrame2 = myHTMLDoc.frames(0).document
     
        'set myHTMLFrame2_3 as the 3rd frame of myHTMLFrame2
        Dim myHTMLFrame2_3 As HTMLDocument
        Set myHTMLFrame2_3 = myHTMLFrame2.frames(1).document
     
        'get all the tables in myHTMLFrame2_3
        Dim allTables As Object
        Set allTables = myHTMLFrame2.getElementsByTagName("Table")
     
        'set myTable as the 3rd table in allTables
        Dim myTable As HTMLTable
        Set myTable = allTables(2)
     
         For Row = 1 To myTable.Rows.Length
            For Col = 1 To myTable.Rows(Row - 1).Cells.Length
              If myTable.Rows(Row - 1).Cells(Col - 1).innerText = "Data Extraction" Then
                ash = myTable.Rows(Row - 1).Cells(Col - 1).ID
    ''''''''''''''code for clicking button
                myHTMLFrame2 .getelementbyid(ash).click    <-------doesnt work any other suggestions.
              End If
            Next Col
        Next Row

  8. #8
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    If you can share screen using teamviewer, I can have a look after I am home.
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  9. #9
    Junior Member
    Join Date
    Mar 2013
    Posts
    20
    Rep Power
    0
    Hi fox thanks for the reply when you can be home im at office till 8:30 IST so if you get me some code to click on the tabel urls and to change combobox value
    in ie i checked from my end i am sucessuful to get the details of the buttons via inertext but not able to select value or change the selected index

    Just wanna let u know that its an url which i want a click to be send. i have done so far please help.

    Code:
    Public Sub ie_interface()
        Dim ie As Object
        
            Set ie = CreateObject("InternetExplorer.Application")
                   ie.navigate Sheet1.URL_text.Text
                  
           Sheet1.Pro_text1.Visible = True
           Sheet1.Pro_text2.Visible = True
        Application.ScreenUpdating = True
           cnt2 = Sheet1.Pro_text1.Width
           Do While ie.Busy
           If cnt < cnt2 Then
            Sheet1.Pro_text2.Width = cnt
            cnt = cnt + 2
            Application.Wait Now() + TimeValue("00:00:02")
           End If
           Loop
    
      Sheet1.Pro_text2.Width = cnt2
      Application.Wait Now() + TimeValue("00:00:02")
      Sheet1.Pro_text2.Width = 0
     cnt = 0
     cnt2 = 0
     
     Sheet1.Pro_text1.Visible = False
     Sheet1.Pro_text2.Visible = False
    ie.Visible = True
    Application.Wait Now() + TimeValue("00:00:02")
    ie.document.Login.UserName.Value = Sheet1.User_text.Text
    ie.document.Login.UserPassword.Value = Sheet1.Pass_text.Text
    ie.document.getElementById("Submit").Click
    
    Do While ie.Busy
    Loop
    Application.Wait Now() + TimeValue("00:00:01")
    Application.SendKeys ("%{ }X")
    Application.Wait Now() + TimeValue("00:00:01")
    ie.document.forms(0).all("m8").Click
    Application.Wait Now() + TimeValue("00:00:02")
    Application.SendKeys ("{TAB 3}")
    Application.Wait Now() + TimeValue("00:00:02")
    Application.SendKeys ("{TAB 4}~")
    Application.Wait Now() + TimeValue("00:00:02")
    
     Dim myHTMLDoc As HTMLDocument
        Set myHTMLDoc = ie.document
     
        'set myHTMLFrame2 as the 2nd frame of the main page (index starts at 0)
        Dim myHTMLFrame2 As HTMLDocument
        Set myHTMLFrame2 = myHTMLDoc.frames(0).document
     
        'set myHTMLFrame2_3 as the 3rd frame of myHTMLFrame2
        Dim myHTMLFrame2_3 As HTMLDocument
    '    Set myHTMLFrame2_3 = myHTMLFrame2.frames(1).document
     
        'get all the tables in myHTMLFrame2_3
        Dim allTables As Object
        Set allTables = myHTMLFrame2.getElementsByTagName("Table")
     
        'set myTable as the 3rd table in allTables
        Dim myTable As HTMLTable
        Set myTable = allTables(7)
     
         For Row = 1 To myTable.Rows.Length
            For Col = 1 To myTable.Rows(Row - 1).Cells.Length
            If myTable.Rows(Row - 1).Cells(Col - 1).innerText = "Data Extraction" Then
                myTable.Rows(Row - 1).Cells(Col - 1).Click 
              End If
            Next Col
        Next Row
        
        
        ie.Visible = True
    
    End Sub

  10. #10
    Junior Member
    Join Date
    Mar 2013
    Posts
    20
    Rep Power
    0
    At last i completed it with lots of R&D and googling i got it worked posted the code for your refrence.

    Code:
    Set myHTMLDoc = ie.document
            
      Set myHTMLFrame2 = myHTMLDoc.frames(0).document
      Set htmlDoc = myHTMLFrame2
    
        Set link = Nothing
        i = 0
        While i < htmlDoc.Links.Length And link Is Nothing
            If htmlDoc.Links(i).innerText = "Data Extraction" Then Set link = htmlDoc.Links(i)
            i = i + 1
        Wend
        If Not link Is Nothing Then
            link.Focus
            link.Click
        Else
            
        End If
        Set theFrame = Nothing

Similar Threads

  1. Replies: 17
    Last Post: 07-15-2013, 09:56 PM
  2. Replies: 1
    Last Post: 05-22-2013, 01:50 PM
  3. VBA IE Internet Explorer Automation Through ElementID
    By mrmmickle1 in forum Excel Help
    Replies: 3
    Last Post: 01-22-2013, 06:20 AM
  4. Replies: 7
    Last Post: 06-09-2012, 06:45 PM

Posting Permissions

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