Excel VBA导入xml文件 [英] Excel VBA import xml file

查看:673
本文介绍了Excel VBA导入xml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用过谷歌,但我似乎找不到以下问题的简单答案:

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

如何将XML文件导入Excel工作表使用VBA。所以例如,我在文件夹c:\test中有一个名为test.xml的文件。我想要excel将test.xml的数据复制到第二页使用VBA

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数据导入

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")

从此开始,看看它是否适用于您的文件。如果遇到问题,您需要发布实际XML的示例。

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.

这篇关于Excel VBA导入xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆