'Export data from mapped excel to XML using Macro

I am trying to export the mapped the data from Excel to XML . Name of Mapped file to : 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



Solution 1:[1]

Specify the overwrite argument as True otherwise you will get

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

if the file already exists.

Not specifying, or setting explicitly to False, will create the file at the URL.

E.g.

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

XmlMap.Export Method

expression.Export(Url, Overwrite)

Overwrite > Optional > Variant > Set to True to overwrite the file specified in the URL parameter if the file exists. The default value is False.

Solution 2:[2]

QHarr gives the decisive hint and explanation, with this Link. And the exactly Syntax looks like this:

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

Solution 3:[3]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 QHarr
Solution 2 ihrEvg
Solution 3 ack