我在VBA-Excel中有一个代码,我可以在其中导航到一个网页,然后登录,然后移至该站点内的另一个URL。到目前为止,一切似乎都运行良好,但是在完成所有操作之后,我确实需要单击站点中的链接(位于框架部分)。我有以下执行单击的代码,并且我认为它起作用,因为弹出/模态窗口随下一页打开,这是我需要填写的表格。
For Each oHTML_Element In HTMLdoc_F.getElementsByTagName("a")
Debug.Print oHTML_Element.innerText
If oHTML_Element.innerText = "Persona Natural " Then
oHTML_Element.Click
Loop Until HTMLdoc_F.readyState = READYSTATE_COMPLETE
Exit For
End If
Next
问题是执行oTHML_Element.click行时,它会打开链接,但永远保持在同一行中。我尝试了FireEvent onclick其他方法,结果是相同的。
html部分是这样:
<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Untitled Document</title>
<meta http-equiv="X-UA-Compatible" content="IE=7">
<script language="javascript">
function ShowfrmIndividual(){
window.showModalDialog("Response.ASP?WCI=TIndividual&WCU=&RoleTypeId=1&CustomerTypeId=1&Cached=0","Dialog Arguments Value","dialogHeight: 570px; dialogWidth: 800px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: Yes; status: No;");
return false;
}
</script></head>
<body bgcolor="#efebef" link="#ffffff" vlink="#efebef" alink="#efebef" ms_positioning="GridLayout">
<table border="0" width="1359" bgcolor="#ff7908" height="20" cellspacing="0" cellpadding="0" style="left: 0; position: absolute; top: 0; z-index: 6">
<tbody><tr>
<td width="100%"></td>
</tr>
</tbody></table>
<a style="FONT-SIZE: 10pt; Z-INDEX: 1; LEFT: 210px; MARGIN-LEFT: 0px; WIDTH: 56px; TEXT-INDENT: 0px; MARGIN-RIGHT: 0px; FONT-FAMILY: MS Serif; POSITION: absolute; TOP: 121px; HEIGHT: 16px; TEXT-ALIGN: left" onclick="return ShowfrmIndividual()" href="https://www.anysite.cl/Chile/RWeb/Response.ASP?WCI=TMainWelcome&amp;WCU=&amp;amp;WCE=eActivities&amp;amp;WCU">...para una</a>
<a style="FONT-SIZE: 10pt; Z-INDEX: 1; LEFT: 210px; MARGIN-LEFT: 0px; WIDTH: 110px; TEXT-INDENT: 0px; MARGIN-RIGHT: 0px; FONT-FAMILY: MS Serif; POSITION: absolute; TOP: 135px; HEIGHT: 16px; TEXT-ALIGN: left" onclick="return ShowfrmIndividual()" href="https://www.anysite.cl/Chile/RWeb/Response.ASP?WCI=TMainWelcome&amp;WCU=&amp;amp;WCE=eActivities&amp;amp;WCU"> Persona Natural </a>
</form></body></html>
感谢您的帮助。