Test the folowing codes,please:
Sub Selecttable(ByVal url As String, ByVal n As Long) Dim t, r As Object, i As Long WebBrowser1.Navigate url, False Do While Sheet1.WebBrowser1.readyState <> 4 DoEvents Loop For Each t In WebBrowser1.Document.All If LCase(t.tagName) = "table" Then i = i + 1 If i > n Then WebBrowser1.Stop Set r = .WebBrowser1.Document.body.createControlRange() r.Add (t) r.execCommand ("SelectAll") Exit For End If End If Next End Sub
本文介绍了一段使用VBA编写的脚本,该脚本可以实现在Web页面中定位并选择指定序号后的第一个表格。通过浏览器控件加载网页,并利用DOM操作选取目标元素。
5900

被折叠的 条评论
为什么被折叠?



