PDA

View Full Version : Unable to Get ElementID In VBA IE Automation



ashu1990
03-21-2013, 06:16 PM
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.


<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>

Excel Fox
03-21-2013, 07:07 PM
It's hard to say from the source code. Post the URL, and indicate which element it is.

ashu1990
03-21-2013, 07:29 PM
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
643




<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','Escrow Admin','');
return false;
}
function CheckLoanID()
{
if(isNaN(parseFloat(document.getElementById(GetCli entID("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=t rue" 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="/wEPDwUKLTQ2ODM2NTc0Mw8WAh4IUGFnZVNpemUCFBYCAgMPFgI eDEF1dG9Db21wbGV0ZQUDb2ZmFlxmDxYCHgxEZXNpZ25UaW1lS UQFEmhkbkxhc3RGb2N1c0N0cmxJRGQCAQ9kFgJmD2QWAmYPZBY CZg9kFgJmD2QWBGYPFgIfAgULaGRuQ2FsbGVkYnlkAgIPFgIfA gUMVGFibGVTdWJNZW51FgJmD2QWAmYPZBYCZg9kFgJmD2QWJGY PFgIfAgUUQ2FzZURpc3RyaWJ1dGlvbl8yMTkWAmYPD2QWAh8CB QRhMjE5ZAIBDxYCHwIFB1NlcF8yMjBkAgIPFgIfAgUOVG90YWx DYXNlc18yMjAWAmYPD2QWAh8CBQRhMjIwZAIDDxYCHwIFB1Nlc F8yMjFkAgQPFgIfAgUQUHJvZHVjdGl2aXR5XzIyMRYCZg8PZBY CHwIFBGEyMjFkAgUPFgIfAgUHU2VwXzIxMWQCBg8WAh8CBRJBb GxvY2F0aW9uR3JpZF8yMTEWAmYPD2QWAh8CBQRhMjExZAIHDxY CHwIFB1NlcF8yMTJkAggPFgIfAgULRHVlRGF0ZV8yMTIWAmYPD 2QWAh8CBQRhMjEyZAIJDxYCHwIFB1NlcF8yMjJkAgoPFgIfAgU XUmVzb3VyY2VVdGlsaXphdGlvbl8yMjIWAmYPD2QWAh8CBQRhM jIyZAILDxYCHwIFB1NlcF8yMjNkAgwPFgIfAgUSRGF0YUV4dHJ hY3Rpb25fMjIzFgJmDw9kFgIfAgUEczIyM2QCDQ8WAh8CBQdTZ XBfMjI2ZAIODxYCHwIFDVNMQVJlcG9ydF8yMjYWAmYPD2QWAh8 CBQRhMjI2ZAIPDxYCHwIFB1NlcF8yMjdkAhAPFgIfAgUSUmVjb 25jaWxsYXRpb25fMjI3FgJmDw9kFgIfAgUEYTIyN2QCEQ9kFgJ mD2QWAmYP</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=0OEOIgTBPMMWr1XWhIR5pShQLVXCnDYK XzERNKpRH4mVXeH0kM2_SEP1j0DPIyRKYfQDYod9y7YncEuMqC NQ23nL00w1&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=63420897675754 6466" 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+uEKAoDg47QHAsKF0NgIAtKKoeMDAtHlx44 PAsLli40PApGdvqwGAoLuu/MJAv22u8cNAsbZ3e0HAreE/60BAoLut/MJAoLuv/MJAvqkqNkIArnHmcYHApiv4doLAvqkpNkIArnHncYHAoyK5IcM ArnHlcYHAsbZpewHApivmdoLApGdgqwGApGdhqwGAreE+60BAo yK4IcMAvqkoNkIAqvj/5oKAv22g8cNAreE960BAqvjw5oKApivndoLApHUhrMPAtPe9+g OAu/+v90MArSntucKAob1jLgKAsCA944IArGdp8wDAojcsPgLAq21o LoEArK1oLoEArO1oLoEArC1oLoEArG1oLoEAra1oLoEAre1oLo EAu+ekuQKArOcno8BArnikO0PArzB8vwJArPSr8ENAp3RmdUJA uSJu6cKAoS+srcCAp+x3YkGApuQvpUCAornkLELAsP0pT4Cvqb a2AgC47/51QwC0fLM1QICzbz+iQsC7aayjwsC44m95gYCvrTp1wcCxPubu w0Cydvn+w4C3Z2F+gICsKyyBgLb5roBAryB4+8PAsyu3OcBAra p84ICArnpuYgHAqjVko0PArvXjoUKApW0rO8CAtWI2okIAuO64 OUFAu6piQ0Ct9yW0wMCjJT63gsC0JP1vw0C+5KFogcCnazAqA8 C6+zfuQ8CyIffjwwC0dWWuwYCy9fD1wcCge7o/A0C3KKQnAQC/7Px4A4C4rOV4w4C4rON4w4C5rOF4w4C4rOB4w4Clr30kA8Ckdr W6AwC7ZrH+QcC6fKGtwkC4oaLrgsCjvquowcCn9TO3Q8C4tmC5 w8Ct/PtTwLklN+BBwLz8uubAgLr24L6DgKbvdTsDAKF7+a8CgLW66H0 DwLsyuLvCQLQ4L+dAQLjhJP1AwKi7t/1DALv6YbdBALh++WiCAL1qJyMDAKn2pL8CQKjm5WMBrFvsXr4v nRg+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=tr ue')" 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=t rue')" 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=tr ue')" 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=t rue')" 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>

Excel Fox
03-21-2013, 09:40 PM
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


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

ashu1990
03-22-2013, 11:58 AM
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

Excel Fox
03-22-2013, 12:17 PM
I suggest you put a break during code execution, and manually select the control, and then try to figure the ID of the activeElement


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

ashu1990
03-22-2013, 03:41 PM
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.%D


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

Excel Fox
03-22-2013, 04:04 PM
If you can share screen using teamviewer, I can have a look after I am home.

ashu1990
03-22-2013, 05:29 PM
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.:(


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

ashu1990
03-28-2013, 11:58 AM
At last i completed it with lots of R&D and googling i got it worked posted the code for your refrence.:cheers:


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