2

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

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

4 Comments

When i try this Sub Macro2() ActiveWorkbook.XmlMaps("Screens_Map").Export Url:= _ "C:<LocalFile>", True End Sub After this changes , i am seeing `Compiler error Expected: Named Parameter' This error points to the place where i have added "True" in code And Thanks for the suggestion . Please help me over this @QHarr
Have you tried putting this C:<LocalFile>" string into variable myUrl and then doind Url:= myUrl, True ?
At place of <Local file> I have given the location where file need to be dumped .. and other code will remain same as above comment
yes but you are getting a compile error suggesting the path might in some way be 1) invalid or 2) containing a character causing a problem for this method. Have you verified the path? As an aside, I assume you have done .IsExportable test in advance ( this wouldn't generate the same error but worth doing anyway) Oh: Sorry and put , Overwrite:= True and put the whole thing on one line.
0

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

Comments

0
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

1 Comment

Remember that Stack Overflow isn't just intended to solve the immediate problem, but also to help future readers find solutions to similar problems, which requires understanding the underlying code. This is especially important for members of our community who are beginners, and not familiar with the syntax. Given that, can you edit your answer to include an explanation of what you're doing and why you believe it is the best approach?