嗨,我正在将整个表格从网站导入到 excel 字符串:
Dim fST As String
fST = Doc.getElementsByTagName("table")(0).innerText
之后我想在excel单元格中拆分表格并使用<td>
html表格中的标签进行拆分,或者至少这是我认为可以完成的选项,因此导入的表格在excel中将是相同的导入后,每个值都将位于单个单元格内。
让我知道谢谢。
这是我正在使用的整个 conde:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = Range("URL").Row And _
Target.Column = Range("URL").Column Then
Dim IE As New InternetExplorer
IE.Visible = True
IE.navigate Application.ActiveSheet.Range("URL")
Do
DoEvents
Loop Until IE.readyState = READYSTATE_COMPLETE
Dim Doc As HTMLDocument
Set Doc = IE.document
Dim tbl, trs, tr, tds, td, r, c
Set tbl = Doc.getElementsByTagName("table")(0)
Set trs = tbl.getElementsByTagName("tr")
For r = 1 To trs.Count
Set tds = trs(r).getElementsByTagName("td")
For c = 1 To tds.Count
ActiveSheet.Cells(r, c).Value = tds(c).innerText
Next c
Next r
IE.Quit
End If
End Sub
但它说错误:对象不支持以下行中的此属性或方法: For r = 1 To trs.Count