SaveAsXMLData Method
TOC
Collapse the table of content
Expand the table of content

Workbook.SaveAsXMLData Method (Excel)

Office 2013 and later
GitHub-Mark-64px

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

Exports the data that has been mapped to the specified XML schema map to an XML data file.

expression .SaveAsXMLData(Filename, Map)

expression A variable that represents a Workbook object.

Parameters

Name

Required/Optional

Data Type

Description

Filename

Required

String

A string that indicates the name of the file to be saved. You can include a full path; if you don't, Microsoft Excel saves the file in the current folder.

Map

Required

XmlMap

The schema map to apply to the data.

This method will result in a run-time error if Excel cannot export data with the specified schema map. To check whether Excel can use the specified schema map to export data, use the IsExportable property.

The following example verifies that Excel can use the schema map "Customer" to export data, and then exports the data mapped to the "Customer" schema map to a file named "Customer Data.xml".

Sub ExportAsXMLData() 
 Dim objMapToExport As XmlMap 
 
 Set objMapToExport = ActiveWorkbook.XmlMaps("Customer") 
 
 If objMapToExport.IsExportable Then 
 
 ActiveWorkbook.SaveAsXMLData "Customer Data.xml", objMapToExport 
 Else 
 MsgBox "Cannot use " & objMapToExport.Name & _ 
 "to export the contents of the worksheet to XML data." 
 End If 
End Sub
Show:
© 2016 Microsoft