|
原帖由 ldy 于 2009-12-10 11:47 发表
看图片来说,和附件中的获取股票数据的例子一样. 修改文字特征就行了 红色字就是需要的Table中出现的文字
Private Sub CommandButton26_Click()
Set dmt = WebBrowser1.Document
For i = 0 To dmt.al ...
谢谢,版主的回复!~!在研究中!~想把黄色的地方获取时不取出来!请问怎么修改代码!@·
我用货号也可以。
Private Sub CommandButton2_Click()
Sheet1.Activate
Sheet1.Cells.Clear
r = Range("B65536").End(xlUp).Row
Call Asheet
Call Bsheet
Cells.EntireColumn.AutoFit
MsgBox "保存网页数据完毕!", vbInformation
End Sub
Sub Asheet()
Sheet1.Select
Set dmt = WebBrowser1.Document
For i = 0 To dmt.all.tags("table").Length - 1
If InStr(dmt.all.tags("table")(i).innerText, "订单编号") > 0 Then x = i
Next
Set r = dmt.all.tags("table")(x).Rows
For i = 0 To r.Length - 1
For j = 0 To r(i).Cells.Length - 1
Sheet1.Cells(j + 1, i + 1) = r(i).Cells(j).innerText
Next
Next
End Sub
Sub Bsheet() '表体部分,明细数据
Sheet1.Select
Set dmt = WebBrowser1.Document
For i = 0 To dmt.all.tags("table").Length - 1
If InStr(dmt.all.tags("table")(i).innerText, "订购数量") > 0 Then x = i
Next
Set r = dmt.all.tags("table")(x).Rows
For i = 0 To r.Length - 1
For j = 0 To r(i).Cells.Length - 1
t = 7 '从第7列开始填充
Sheet1.Cells(i + 1, j + 1 + t) = r(i).Cells(j).innerText
Next
Next
End Sub
[ 本帖最后由 zhua 于 2009-12-10 17:39 编辑 ] |
-
|