简体   繁体   English

使用宏将数据从映射的 excel 导出到 XML

[英]Export data from mapped excel to XML using Macro

I am trying to export the mapped the data from Excel to XML.我正在尝试将映射的数据从 Excel 导出到 XML。 Name of Mapped file to: Screens_Map映射文件的名称:Screens_Map

Below is my Code of Macro下面是我的宏代码

Sub Macro1() ActiveWorkbook.XmlMaps("Screens_Map").Export Url:= _ "c:\<LocalFile>" End Sub

When I run this code, I am seeing this error当我运行这段代码时,我看到了这个错误

run time error '-2147467259(80004005) 
Method export of object XMLMap failed 

Please Help over this请帮忙解决这个问题

Specify the overwrite argument as True otherwise you will get将覆盖参数指定为True否则你会得到

Run time error '-2147467259(80004005) Method export of object XMLMap failed运行时错误 '-2147467259(80004005) 对象 XMLMap 的方法导出失败

if the file already exists.如果文件已经存在。

Not specifying, or setting explicitly to False , will create the file at the URL.不指定或明确设置为False将在 URL 处创建文件。

Eg例如

 ActiveWorkbook.XmlMaps("Screens_Map").Export Url:= _
        "c:\<LocalFile>", True

XmlMap.Export Method XmlMap.Export 方法

expression.Export(Url, Overwrite) expression.Export(Url, Overwrite)

Overwrite > Optional > Variant > Set to True to overwrite the file specified in the URL parameter if the file exists. Overwrite > Optional > Variant > 设置为 True 以覆盖 URL 参数中指定的文件(如果文件存在)。 The default value is False.默认值为假。

QHarr gives the decisive hint and explanation, with this Link . QHarr 通过这个Link给出了决定性的提示和解释。 And the exactly Syntax looks like this:确切的语法如下所示:

 Sub Macro1()
    ActiveWorkbook.XmlMaps("Screens_Map").Export Url:= _
        "c:\<LocalFile>", _
         Overwrite:= True
End Sub
Sub Macro1()
    Set xmap = ActiveWorkbook.XmlMaps("Document_Mappage1")
    If xmap.IsExportable Then
        URL = "C:\XML_FILE\Liste2_SEPA_Type_RCUR.xml"
        xmap.Export URL, True
    End If
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM