我用以下代码, 试图访问一个网页table中第1行第1列的内容, 并msgbox出来
为什么连msgbox都不弹出?
怎样改才能做到?
请注意这个网页中只有1个table, table没有设ID,table中的单元格也没有设IDPrivate Sub Command4_Click()
Dim IEList As New ShellWindows
Dim browser
On Error Resume Next
For Each browser In IEList
If InStr(browser.LocationName, "2009年黑") Then
MsgBox (browser.Document.tables(0).trs(0).tds(0).Value) End If
Next
End Sub
为什么连msgbox都不弹出?
怎样改才能做到?
请注意这个网页中只有1个table, table没有设ID,table中的单元格也没有设IDPrivate Sub Command4_Click()
Dim IEList As New ShellWindows
Dim browser
On Error Resume Next
For Each browser In IEList
If InStr(browser.LocationName, "2009年黑") Then
MsgBox (browser.Document.tables(0).trs(0).tds(0).Value) End If
Next
End Sub
Dim Tables As IHTMLElementCollection
Set Tables = doc.getElementsByTagName("Table") Dim Table As IHTMLTable Set Table = Tables(0)
Dim Row As HTMLTableRow, Cell As HTMLTableCell
Set Row = Table.rows.Item(0)
Set Cell = Row.cells.Item(0) MsgBox Cell.innerHTML
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) http://feiyun0112.cnblogs.com/
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) http://feiyun0112.cnblogs.com/
Private Sub Command3_Click()
Dim IEList As New ShellWindows
Dim browser
On Error Resume Next
For nCount = 2 To 5
For Each browser In IEList
If InStr(browser.LocationName, "2009年黑") Then
browser.Document.Forms("form1").zkzh.Value = xlSheet.Cells(nCount, 1)
browser.Document.Forms("form1").ksxm.Value = xlSheet.Cells(nCount, 2)
browser.Document.Forms("form1").submit.Click
MsgBox ("Wait")
End If
Next
Next
End Sub
Private Sub Command4_Click()
Dim IEList As New ShellWindows
Dim browser
Dim Table As IHTMLTable
Dim Tables As IHTMLElementCollection
Set Tables = doc.getElementsByTagName("Table")
Set Table = Tables(0)
Dim Row As HTMLTableRow, Cell As HTMLTableCell
Set Row = Table.rows.Item(0)
Set Cell = Row.cells.Item(0)
On Error Resume Next
For Each browser In IEList
If InStr(browser.LocationName, "2009年黑") Then
MsgBox (browser.Tables(0).trs(0).tds(0).Value)
MsgBox Cell.innerHTML
End If
Next
End Sub不知您代码Set Tables = doc.getElementsByTagName("Table")红色的Table是什么,是表格的名字或ID?,可是这个网页的Table是没有ID的
If InStr(browser.LocationName, "2009年黑") Then set doc=browser.document
Set Tables = doc.getElementsByTagName("Table")
Set Table = Tables(0)
Dim Row As HTMLTableRow, Cell As HTMLTableCell
Set Row = Table.rows.Item(0)
Set Cell = Row.cells.Item(0) MsgBox (browser.Tables(0).trs(0).tds(0).Value)
MsgBox Cell.innerHTML
End If
Next