【发布时间】:2014-01-26 23:21:03
【问题描述】:
我是 excel vba 编程的新手。从近 3 天开始,我一直在尝试使用 excel vba 单击网页上的超链接。请帮帮我。因为我是新手,所以我可能犯了很多错误。请原谅我。
场景是: 一个特定的网页有一个表格,第一列是一个图标,第二列是一个超链接,还有几列是关于超链接的一些描述。
现在,我想单击第一行(第二列)中的超链接。 当我们将鼠标悬停在同一行(第一列)中的图标上时,会显示相同的超链接。
此网页是动态的,因此表格会不断变化。实际上该表是输入的搜索条件的结果。
三天以来,我写了很多代码。 这是最新的不工作的:
'获取行的元素id
With elementid = ieApp.document.all.Item("abcrow1")
'checking for details with tagname as "a"
Set tagname = ieApp.document.getElementByTagName("a")
For Each tag In tagname
'Get value of the href
hrefvalue = tag.href.value
If Not IsNull(hrefvalue) Then
If hrefvalue <> "javascript:void(0);" Then 'this href is usedto describe the icon
hrefvalue = ieApp.document.href.value
hrefvalue = "https://www.secur.com" & hrefvalue
ieApp.Navigate hrefvalue
Exit For
End If
End IF
Next tag
End With
HTML脚本如下:
<tr id = "abcrow1" class="e1">
<td class = "icon"></td>
<td><ul class="xyz" id="link">
<li><a href = "javascript:void(0);"><img src="/nnn.gif" border = 0 alt = "info" </a>
<ul>
<li><a onclick ="return cursorWait(this);" href = "/xyz/lmo">DetailOfRow1</a></li></ul></td>
<td style = "text-align:left"><aonclick="return cursorWait(this);" href = "/xyz/lmo">DetailOfRow1</a></td></tr>
请帮帮我。谢谢。
【问题讨论】:
标签: excel hyperlink webpage vba