下面这个Excel Vba读取XML教程由图老师小编精心推荐选出,过程简单易学超容易上手,喜欢就要赶紧get起来哦!
【 tulaoshi.com - Excel教程 】
如下代码示例的功能是,在Excel中,通过VBA代码,读取XML文件中的内容。
Dim rst As ADODB.Recordset
Dim stCon As String, stFile As String
Dim i As Long, j As Long
Set rst = New ADODB.Recordset
stFile = "C:dzwebs.xml"
stCon = "Provider=MSPersist;"
With rst
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com).CursorLocation = adUseClient
.Open stFile, stCon, adOpenStatic, adLockReadOnly, adCmdFile
Set .ActiveConnection = Nothing
End With
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com)With ActiveSheet
For j = 0 To i - 1
.Cells(1, j + 1).Value = rst.Fields(j).Name
Next j
.Range("A2").CopyFromRecordset rst
End With
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com)rst.Close
Set rst = Nothing
来源:http://www.tulaoshi.com/n/20160219/1606069.html
看过《Excel Vba读取XML》的人还看了以下文章 更多>>