convert xml to xls

五迷三道 提交于 2019-12-02 04:03:41

Parse the XML file using DOM, then spit out the relevant values onto your sheet. Here's a trivial working example to get you started:

Dim d As DOMDocument
Dim n As IXMLDOMNode
Dim s As String

Set d = New DOMDocument
d.async = False 
d.Load "http://www.democracynow.org/podcast-video.xml" ' or "C:\myfile.xml"

Set n = d.SelectSingleNode("//channel/description")
s = n.Text
Range("A1") = s

This early binding requires a reference set as follows: Tools > References... > Microsoft XML

Note that d.async = False forces the load to complete before proceeding further; this is especially important when loading remote files.

You want to

update the spreadsheet every time it's opened with little or no user interaction (ie, i'd prefer to not have to tell people to run a macro)."

Then put the macro in the Workbook_Open event! That's what it's there for.

Where is the xml file? is this location fix?

If yes, you can create a dataconnection in Excel to this xml file.

Then setup the xml connection to refresh when the excel file opens.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!