Sub test()
Dim myQuery
With ActiveSheet
.Cells.Delete
.[a1] = "Conneting, Please Wait..."
Set myQuery = ActiveSheet.QueryTables _
.Add(Connection:="URL", _
Destination:=.Cells(1, 1))
End With
With myQuery
.Refresh
End With
补充:grhsc你不是知道读取全部网页的程序吗?那里可以先把整个网页以表格的方式读取到excel中,建立一个临时sheet,然后删除掉多余的数据,或者在excel中在读取需要的数据不就行了?
Private Sub Command1_Click()Dim xmldoc As Object
Set xmldoc = CreateObject("msxml2.domdocument") 'xmlDocment对象
xmldoc.async = False '同步载入方式
xmldoc.Load "C:\sample.xml" '载入xml文件
Dim Root As Object
Set Root = xmldoc.documentElement '获取根结点
Dim arU As Integer
arU = Root.childNodes.length - 1 '根结点的子结点数-1为数组下标
Dim strImage() As String
Dim strDelay() As String
Dim strX() As String
Dim strY() As String
'定义数组下标量
ReDim strImage(arU)
ReDim strDelay(arU)
ReDim strX(arU)
ReDim strY(arU)
Dim i As Integer
Dim C As Object
'获取每个子结点的属性值
For Each C In Root.childNodes
strImage(i) = C.Attributes.getNamedItem("image").Text
strDelay(i) = C.Attributes.getNamedItem("delay").Text
strX(i) = C.Attributes.getNamedItem("x").Text
strY(i) = C.Attributes.getNamedItem("y").Text
i = i + 1
Next
'显示数组内容
Print Join(strImage, vbCrLf)
Print Join(strDelay, vbCrLf)
Print Join(strX, vbCrLf)
Print Join(strY, vbCrLf)
End Sub
思路:用split函数将xml分割,如resulttmp=split(str1,“PRODUCT_NAME=”)此时数组resulttmp(1)="11" PRODUCT_VERSION="x" DESC=……
然后再用PRODUCT_VERSION=分割,分割后的数组(0)即为“11”
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)