XmlImportXml Method

Microsoft Excel Visual Basic

Show All Show All

XmlImportXml Method

Note  XML features, except for saving files in the XML Spreadsheet format, are available only in Microsoft Office Professional Edition 2003 and Microsoft Office Excel 2003.

Imports an XML data stream that has been previously loaded into memory. Returns XlXmlImportResult.

XlXmlImportResult can be one of the following XlXmlImportResult constants
xlXmlImportElementsTruncated The contents of the specified XML data file have been truncated because the XML data file is too large for the worksheet.
xlXmlImportSuccess The XML data file was successfully imported.
xlXmlImportValidationFailed The contents of the XML data file do not match the specified schema map. The file was not imported.

expression.XmlImportXml(Data, ImportMap, Overwrite, Destination)

expression    Required. An expression that returns one of the objects in the Applies To list.

Data   Required String. The data to import.

ImportMap   Required XmlMap. The schema map to apply when importing the file.

Overwrite   Optional Boolean. If a value is not specified for the Destination parameter, then this parameter specifies whether or not to overwrite data that has been mapped to the schema map specified in the ImportMap parameter. Set to True to overwrite the data or False to append the new data to the existing data. The default value is True. If a value is specified for the Destination parameter, then this parameter specifies whether or not to overwrite existing data. Set to True to overwrite existing data or False to cancel the import if data would be overwritten. The default value is True.

Destination    Optional Range. The data will be imported into a new XML list in the range specified.

Remarks

Don't specify a value for the Destination parameter if you want to import data into an existing mapping.

The following conditions will cause the XMLImport method to generate run-time errors:

  • The specified XML data contains syntax errors.
  • The import process was cancelled because the specified data cannot fit into the worksheet.

Use the XmlImport method of the Workbook object to import an XML data file into the current workbook.