下面的程序可以正常将表格中的文本写入文件
Dim Tables, T As IHTMLElementCollection
Set doc = WebBrowser1.Document
Set T = WebBrowser1.Document.frames(1).Document.getElementsByTagName("TABLE")
Set Tables = T.Item(0, 0).All.tags("Table").Item(4, 4)
Open "C:\test.TXT" For Output As #1
For i = 0 To Tables.rows.length - 1
Set ROW = Tables.rows(i)
tmp = ""
For j = 0 To Tables.cells.length / Tables.rows.length - 1
tmp = tmp & "," & ROW.cells(j).innerText
Next
Print #1, tmp
Next
Close #1
但是我想实现逐个点击表格中的每一行,查看了好多资料都没有,恳请各位给出个好主意,明确一下我应该如何实现
Dim Tables, T As IHTMLElementCollection
Set doc = WebBrowser1.Document
Set T = WebBrowser1.Document.frames(1).Document.getElementsByTagName("TABLE")
Set Tables = T.Item(0, 0).All.tags("Table").Item(4, 4)
Open "C:\test.TXT" For Output As #1
For i = 0 To Tables.rows.length - 1
Set ROW = Tables.rows(i)
tmp = ""
For j = 0 To Tables.cells.length / Tables.rows.length - 1
tmp = tmp & "," & ROW.cells(j).innerText
Next
Print #1, tmp
Next
Close #1
但是我想实现逐个点击表格中的每一行,查看了好多资料都没有,恳请各位给出个好主意,明确一下我应该如何实现
Set doc = WebBrowser1.Document
Set T = WebBrowser1.Document.frames(1).Document.getElementsByTagName("TABLE")
Set Tables = T.Item(0, 0).All.tags("Table").Item(4, 4)
For i = 0 To Tables.rows.length - 1
Set ROW = Tables.rows(i)
Call ROW.click()
Next
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
xxxxx系统
</title>
<style>
.navPoint
{
font-family: Webdings;
font-size:9pt;
color:white;
cursor:hand;
}
p{
font-size:9pt;
}
</style> <script>
function switchSysBar(){
if (switchPoint.innerText==3){
switchPoint.innerText=4
document.all("frmTitle").style.display="none"
}
else{
switchPoint.innerText=3
document.all("frmTitle").style.display=""
}
}
</script></head>
<body scroll="no" style="margin: 0px">
<table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
<tr>
<td id="frmTitle" name="frmTitle" nowrap valign="middle" align="center">
<iframe id="BoardTitle" name="main" scrolling="auto" style="height: 100%; visibility: inherit; width: 250;
z-index: 2" frameborder="0" src="leftsubmit.aspx"></iframe>
<td style="width: 10pt" background="images/t2.gif">
<table cellspacing="0" cellpadding="0" border="0" height="100%">
<tr>
<td style="height: 100%" onclick="switchSysBar()">
<span class="navPoint" id="switchPoint" title="关闭/打开左栏">3</span>
</table>
</td>
<td style="width: 100%">
<iframe id="frmright" name="BoardList" style="height: 100%; visibility: inherit;
width: 100%; z-index: 1" scrolling="auto" frameborder="0" src="main.aspx"></iframe>
</tr>
</table>
</body>
</html>