另存为XML与VBA? [英] Save as XML with VBA?

查看:130
本文介绍了另存为XML与VBA?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将Excel表保存为XML?我有XML Schema文件...和表中的一些数据...我在Excel中有另存为XML文件选项,但是可以从VBA将文件保存为XML吗?我想自动化一个进程,我没有找到任何东西在这个选项。谢谢!

解决方案

好的ol'宏记录器保存了我这次:))(为什么我没有使用它之前发布在这里?)
所以...
加载一个xml模式你有:

  ActiveWorkbook。 XmlMaps.Add(Book2.xml,raport)。名称_ 
=raport_Map

并将其保存为xml:

  ActiveWorkbook.SaveAsXMLData文件名:=Book3.xml,_ 
Map:= ActiveWorkbook.XmlMaps(raport_Map)

谁会以为这很容易?


Is there any way to save an Excel table as XML? I have the XML Schema file... and some data in a table... and I have in Excel the Save as XML file option but can I save a file as XML from VBA? I want to automate a process and I didn;t find nothing on this option. Thanks!

解决方案

the good ol' macro recorder saved me this time :)) (Why didn't I used it before I posted here?) So... To load an xml schema you have:

ActiveWorkbook.XmlMaps.Add("Book2.xml", "raport").Name _
        = "raport_Map"

And to save it as xml:

ActiveWorkbook.SaveAsXMLData Filename:="Book3.xml", _
        Map:=ActiveWorkbook.XmlMaps("raport_Map")

Who would have thought that it's that easy?

这篇关于另存为XML与VBA?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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