我最近一直在教自己的VBA試圖建立一個代碼,最終登錄到一個網站上載Excel電子表格中的數據。通過Excel的VBA IE自動化 - 無法弄清楚如何操縱Java鏈接/元素
此時代碼將登錄到該網站並瀏覽大部分頁面,直到搜索屏幕出現爲止。發生什麼是我的代碼採取一個唯一的ID號碼拉起個人。在執行搜索之後的下一個屏幕上,該網站提供了一個列表(由於使用了ID號碼,這只是一個人)。我需要能夠「點擊」個人的名字才能繼續,但我似乎無法弄清楚如何去做。
我不能提供我的代碼的實際網站和任何真正的標識符,但我會張貼我希望有人可以幫助的。
這裏是HTML(摘錄),我需要能夠點擊的表格幾乎是任何值在這個塊。
<tr>
<td><input type='hidden' id='grdProfile' name='grdProfile' value="" /><table border='0' cellpadding='0' cellspacing='0' id='grdProfile_main' style="overflow:hidden;table- layout:fixed;position:relative;width:100%;" class="ig_2e49b359_r0 MT" onresize="igtbl_onResize('grdProfile');" onmousemove="igtbl_tableMouseMove (event,'grdProfile');" onmouseup="igtbl_tableMouseUp (event,'grdProfile');"><tr><td align="left" style="overflow:hidden;width:100%;">
<div id='grdProfile_hdiv' onscroll="igtbl_onStationaryMarginScroll(event, 'grdProfile', 'grdProfile_hdiv')" style='overflow:hidden;width:100%;position:relative;'>
<table border='0' cellpadding='0' cellspacing='0' style='position:relative;table-layout:fixed;height:100%;width: 978px;' ' bandNo='0'>thead onmousedown='igtbl_headerClickDown(event,"grdProfile");' onmouseup='igtbl_headerClickUp(event,"grdProfile");' onmouseout='igtbl_headerMouseOut(event,"grdProfile");' onmousemove='igtbl_headerMouseMove(event,"grdProfile");' onmouseover='igtbl_headerMouseOver(event,"grdProfile");' oncontextmenu='igtbl_headerContextMenu(event,"grdProfile");' ondblclick='igtbl_cellDblClick(event,"grdProfile");'>
<tr><th id='grdProfile_c_0_0' columnNo='0' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH "> </th>
<th id='grdProfile_c_0_1' columnNo='1' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;"> </th>
<th id='grdProfile_c_0_2' columnNo='2' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH ">Last Name</th>
<th id='grdProfile_c_0_3' columnNo='3' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH ">First Name</th>
<th id='grdProfile_c_0_4' columnNo='4' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH ">Middle Initial/Name</th>
<th id='grdProfile_c_0_5' columnNo='5' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;">AgentID</th>
<th id='grdProfile_c_0_6' columnNo='6' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH ">SSN</th>
<th id='grdProfile_c_0_7' columnNo='7' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH ">Profile Key</th>
<th id='grdProfile_c_0_8' columnNo='8' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH ">CRD Number</th>
<th id='grdProfile_c_0_9' columnNo='9' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH ">NPN</th>
<th id='grdProfile_c_0_10' columnNo='10' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;">UNID</th>
<th id='grdProfile_c_0_11' columnNo='11' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;">OFFICE_NBR</th>
<th id='grdProfile_c_0_12' columnNo='12' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;">DEPT_NBR</th>
<th id='grdProfile_c_0_13' columnNo='13' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;">FollowupId</th>
<th id='grdProfile_c_0_14' columnNo='14' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;">STATUS</th>
<th id='grdProfile_c_0_15' columnNo='15' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;">REGION</th>
<th id='grdProfile_c_0_16' columnNo='16' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;">RowState</th>
<th id='grdProfile_c_0_17' columnNo='17' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH ">View</th>
<th id='grdProfile_c_0_18' columnNo='18' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;">Login Id</th>
<th id='grdProfile_c_0_19' columnNo='19' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;">Rep Id</th>
<th id='grdProfile_c_0_20' columnNo='20' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;">Special Handling Required?</th>
<th id='grdProfile_c_0_21' columnNo='21' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;">Special Handling Notes</th></tr>
</thead></table></div></td></tr>
<tr id="grdProfile_mr" style=""><td id="grdProfile_mc" align='left' style="width:100%;vertical-align:top;">
<div id="grdProfile_div" style="overflow:hidden;overflow-y:auto;width:100%;" onscroll='igtbl_onScroll(event,"grdProfile");' tabIndexPage='0' hideFocus='true'>
<table id='G_grdProfile' bandNo='0' border='0' cellpadding='0' cellspacing='0' style='table-layout:fixed;width:978px;position:relative;' onSelectStart='igtbl_selectStart(event,"grdProfile");' onmousedown='igtbl_cellClickDown(event,"grdProfile");' onmouseup='igtbl_cellClickUp(event,"grdProfile");' oncontextmenu='igtbl_cellContextMenu(event,"grdProfile");' onmousemove='igtbl_cellMouseMove(event,"grdProfile");' onmouseover='igtbl_cellMouseOver(event,"grdProfile");' onmouseout='igtbl_cellMouseOut(event,"grdProfile");' ondblclick='igtbl_cellDblClick(event,"grdProfile");'>
<colgroup><col width='20px' /><col width='145px' /><col width='143px' /><col width='100px' /><col width='100px' />
<col width='90px' /><col width='100px' /><col width='100px' /><col width='180px' /><col width='1px' style='display:none;' /><col width='1px' style='display:none;' /><col width='1px' style='display:none;' />
<col width='1px' style='display:none;' /><col width='1px' style='display:none;' /><col width='1px' style='display:none;' />
<col width='1px' style='display:none;' /><col width='1px' style='display:none;' /><col width='1px' style='display:none;' /><col width='1px' style='display:none;' />
<col width='1px' style='display:none;' /><col width='1px' style='display:none;' /><col width='1px' style='display:none;' /></colgroup>
<thead style='display:none;' onmousedown='igtbl_headerClickDown(event,"grdProfile");' onmouseup='igtbl_headerClickUp(event,"grdProfile");' onmouseout='igtbl_headerMouseOut(event,"grdProfile");' onmousemove='igtbl_headerMouseMove(event,"grdProfile");' onmouseover='igtbl_headerMouseOver(event,"grdProfile");' oncontextmenu='igtbl_headerContextMenu(event,"grdProfile");'>
<tr><th id='grdProfile_c_0_0' columnNo='0' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH "> </th>
<th id='grdProfile_c_0_1' columnNo='1' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;"> </th>
<th id='grdProfile_c_0_2' columnNo='2' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH "> </th>
<th id='grdProfile_c_0_3' columnNo='3' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH "> </th>
<th id='grdProfile_c_0_4' columnNo='4' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH "> </th>
<th id='grdProfile_c_0_5' columnNo='5' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;"> </th>
<th id='grdProfile_c_0_6' columnNo='6' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH "> </th>
<th id='grdProfile_c_0_7' columnNo='7' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH "> </th>
<th id='grdProfile_c_0_8' columnNo='8' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH "> </th>
<th id='grdProfile_c_0_9' columnNo='9' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH "> </th>
<th id='grdProfile_c_0_10' columnNo='10' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;"> </th>
<th id='grdProfile_c_0_11' columnNo='11' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;"> </th>
<th id='grdProfile_c_0_12' columnNo='12' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;"> </th>
<th id='grdProfile_c_0_13' columnNo='13' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;"> </th>
<th id='grdProfile_c_0_14' columnNo='14' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;"> </th>
<th id='grdProfile_c_0_15' columnNo='15' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;"> </th>
<th id='grdProfile_c_0_16' columnNo='16' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;"> </th>
<th id='grdProfile_c_0_17' columnNo='17' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH "> </th>
<th id='grdProfile_c_0_18' columnNo='18' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;"> </th>
<th id='grdProfile_c_0_19' columnNo='19' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;"> </th>
<th id='grdProfile_c_0_20' columnNo='20' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;"> </th>
<th id='grdProfile_c_0_21' columnNo='21' height='20px' class="ig_2e49b359_r1 ig_2e49b359_r4 GRSHand ig_2e49b359_rh04 GH " style="display:none;"> </th>
</tr></thead>
<tbody style="height:100%">
<tr id='grdProfile_r_0' style='height:20px;' DataKey='XXXXX3658'><td class="ig_2e49b359_r1 GRSHand"><nobr><span id='fup_agentstdsearch_***ID***'>0</span> </nobr></td>
<td iDV="False" class="ig_2e49b359_r1 GRSHand" style="display:none;"><nobr><input type='checkbox' onpropertychange='igtbl_chkBoxChange(event,"grdProfile");' tabindex='-1' /></nobr></td>
<td class="ig_2e49b359_r1 GRSHand"><nobr>***Last***</nobr></td><td class="ig_2e49b359_r1 GRSHand"><nobr>***First***</nobr></td>
<td class="ig_2e49b359_r1 GRSHand"><nobr>***Middle***</nobr></td>
<td class="ig_2e49b359_r1 GRSHand" style="display:none;"><nobr>***ID***</nobr></td>
<td class="ig_2e49b359_r1 GRSHand"><nobr>***ID4***</nobr></td>
<td class="ig_2e49b359_r1 GRSHand"><nobr>***ID2***</nobr></td>
<td class="ig_2e49b359_r1 GRSHand"><nobr> </nobr></td>
<td class="ig_2e49b359_r1 GRSHand"><nobr>***ID3***</nobr></td>
<td class="ig_2e49b359_r1 GRSHand" style="display:none;"><nobr>***ID2***</nobr></td>
<td class="ig_2e49b359_r1 GRSHand" style="display:none;"><nobr>***Center ID***</nobr></td>
<td class="ig_2e49b359_r1 GRSHand" style="display:none;"><nobr>PROD</nobr></td>
<td class="ig_2e49b359_r1 GRSHand" style="display:none;"><nobr>0</nobr></td>
<td class="ig_2e49b359_r1 GRSHand" style="display:none;"><nobr>7040</nobr></td>
<td class="ig_2e49b359_r1 GRSHand" style="display:none;"><nobr> </nobr></td>
<td class="ig_2e49b359_r1 GRSHand" style="display:none;"><nobr> </nobr></td>
<td class="ig_2e49b359_r1 GRSHand"><nobr><a href="javascript:void(0);" onClick="viewProfile('***ID***','***Last*** ***First***');">View Profile Summary</a></nobr></td>
<td class="ig_2e49b359_r1 GRSHand" style="display:none;"><nobr> </nobr></td>
<td class="ig_2e49b359_r1 GRSHand" style="display:none;"><nobr> </nobr></td>
<td class="ig_2e49b359_r1 GRSHand" style="display:none;"><nobr> </nobr></td>
<td class="ig_2e49b359_r1 GRSHand" style="display:none;"><nobr> </nobr></td></tr></tbody></table></div></td></tr></table></td>
這裏是代碼我必須引用我認爲需要點擊的代碼,但我假設一個事件或腳本需要運行。
With IE
While .Busy Or .ReadyState <> 4: DoEvents: Wend
Application.Wait (Now + TimeValue("0:00:02"))
.Document.frames("mainParent").Document.forms("AgentProfileList").Document.getElementById("grdProfile_r_0").Document.getElementById("grdProfile_rc_0_2").Click
End With
任何援助將不勝感激。
感謝您的回覆。我正在努力解決HTML顯示的問題,對不起有多糟糕...... – CasWalker
查看配置文件是我不需要的配置文件。它只鏈接到grdProfile#17框。我相信我需要的是這樣的。如果我通過F12提取代碼,並將工作用作HTML選項,則會列出與該名稱類似的JavaScript。即使我得到它的工作,我也關心可變數據(ID和名稱),因爲我希望每次輸入新人時都能自動工作。這是可能的,或者我可以使用innerText以某種方式來完成? – CasWalker
當你調用函數時,你可以傳遞它任何你想要的代碼。如果該值需要變量,請執行'CallJavascript(「fup_agentstdsearch(''&variableID & "');」)'。不幸的是,如果沒有看到頁面的代碼,就很難確定哪個函數在做這項工作。 –