Excel VBA import xml file

2019-09-20 17:58发布

I've used google but i can't seem to find a simple answer to the following question:

How do I import a XML file into an Excel worksheet using VBA. So for example, i have a file named test.xml in the folder c:\test. I want excel to copy the data of test.xml to the second sheet using VBA

标签: xml excel vba
1条回答
一纸荒年 Trace。
2楼-- · 2019-09-20 18:23

On the Data tab >> Get External Data >> From other sources >> From XML data import

Recording a macro while doing this gave me:

ActiveWorkbook.XmlImport URL:= "C:\Stuff\test.xml", ImportMap:=Nothing, _
                         Overwrite:=True, Destination:=Range("$A$1")

Start with that and see if it works for your file. If you run into problems you'll need to post a sample of the actual XML.

查看更多
登录 后发表回答