我有一個web查詢到一個表,讓我這樣一個表:VBA如果比較TR TD元素
[C] [D] [E]
[A] Events | IP source | IP destination |
[B] MyEvent (1.10) | 192.168.0.1 | 192.168.0.3 |
,給我的信息是這種類型模式的HTML代碼:
<table class="wrapper">
<tbody>
<tr>
<td width="100%" valign="top">
<center>
<div id="contenpanel">
<table id="contenttable" class="full_table_of_events">
<tbody>
<tr class="content" oncontextmenu="blablabla",("src=192.168.0.1&dst=192.168.0.2")></tr>
<tr></tr>
<tr></tr>
</tbody>
</table>
</div>
</center>
</td>
<tr>
</tbody>
</table>
洙我可以通過簡單的c0de獲得的價值從的innerText .innerText完整的價值是:
myEvent (1.10) 192.168.0.1 192.168.0.2
我抓住這個值cristal明確與msgbox,並且我有excel中的這個c0de,它所做的是,看到你是否有工作表上的鼠標,並給了一個Label.form你得到的標題,我有3 label.form的1事件,一個用於源IP和一個用於目標ip,我嘗試查看該線是否存在與c0de的桌面上,但沒有任何反應。
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Eventi.Caption = ActiveCell.Value
Source.Caption = Cells(ActiveCell.Row, ActiveCell.Column + 1)
Destination.Caption = Cells(ActiveCell.Row, ActiveCell.Column + 2)
End Sub
Sub Extract()
Dim URL As String
Dim IE As InternetExplorer
Dim HTMLdoc As HTMLDocument
Dim TRelements As IHTMLElementCollection
Dim TRelement As HTMLTableRow
Dim Chkb0x As IHTMLElementCollection
URL = "https://localhost/events/index.cgi"
Set IE = New InternetExplorer
With IE
.navigate URL
.Visible = True
While .Busy Or .readyState <> READYSTATE_COMPLETE: DoEvents: Wend
Set HTMLdoc = .document
End With
Set TRelements = HTMLdoc.getElementsByTagName("TR")
MsgBox Eventi.Caption & " " & Source.Caption & " " & Destination.Caption
MsgBox "Search Starting..."
For Each TRelement In TRelements
If Trim(TRelement.innerText) = Eventi.Caption & " " & Source.Caption & " " & Destino.Caption Then
MsgBox "Bingo! You have this event"
End If
Next
End Sub
嗯,我希望有人能看到我在做什麼錯我只是想知道是否有辦法做到這一點。
你的意思是什麼都沒有發生? If語句不返回** true **嗎? – glh