这是原始帖子的编辑。
我已经解决了运行时错误和其他一些错误,现在下面的代码可以运行了。我唯一的问题是,没有选择/单击所需的超链接,因此我的代码没有执行我想要的操作。
稍后我会修复发送密钥(毫无疑问,这是一个循环)
来源如下:
<a class="urLnk" id="SRES2_srescrmsbspstlmttplist_gr_table_1_external_id"
onclick="htmlbSubmitLib('CRM_BSP_LIBRARY',this,
'htmlb:link:click:null::CL_CRM_BSP_RESULTLIST::none','mainform',
'SRES2_srescrmsbspstlmttplist_gr_table_1_external_id','EDIT_DETAILS%1',1,'#');return false"
href="#" target="" ct="Link">
<div class="crmSRESEll">
<span class="urFontStd">
<span title="Navigate to C/0000071583" class="urTxtStd" ct="TextView">
C/0000071583
</span>
</span>
</div>
</a>
Sub Test()
Dim HTMLDoc As HTMLDocument 'changed from MSHTML.HTMLDocument
Dim wkbSourceWB As Workbook
Dim SourceShtClm As Worksheet
Set wkbSourceWB = ThisWorkbook 'Set workbook
Set SourceShtClm = wkbSourceWB.Sheets("Claim Summary")
Set IE = New SHDocVw.InternetExplorerMedium ' create a IE
IE.Visible = True ' make it visible
'Application.StatusBar = ".... opening page"
IE.navigate "<very long intranet website>"
Do While IE.readyState = 4: DoEvents: Loop
Application.Wait Time + TimeSerial(0, 0, 4)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Enter}"
Application.Wait Time + TimeSerial(0, 0, 6)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SendKeys "{Tab}"
Application.Wait (Now + 0.000001)
SourceShtClm.Range("N4").Copy
SendKeys "^v"
SendKeys "{Enter}"
Application.Wait Time + TimeSerial(0, 0, 10)
Set HTMLDoc = Nothing
Do While (IE.Busy)
WScript.Sleep (200)
Loop
Application.Wait Time + TimeSerial(0, 0, 1)
Set HTMLDoc = IE.document
Set Hyperlinks = IE.document.getElementsByTagName("A")
For Each hyper_link In Hyperlinks
If hyper_link.innerText = "urLnk" Then
hyper_link.clik
Exit For
End If
Next
End Sub