Import/Export related procedures in class Workbook (Excel VBA)

This page presents procedures from class Workbook related to the theme Import/Export: ExportAsFixedFormat, XmlImport and XmlImportXml

ExportAsFixedFormat

The ExportAsFixedFormat method is used to publish a workbook to either the PDF or XPS format.

ExportAsFixedFormat (Type, Filename, Quality, IncludeDocProperties, IgnorePrintAreas, From, To, OpenAfterPublish, FixedFormatExtClassPtr, WorkIdentity)

ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF

Arguments

The following argument is required

Type (XlFixedFormatType) - Can be either xlTypePDF or xlTypeXPS.

Possible Values are xlTypePDF - "PDF" - Portable Document Format file (.pdf), xlTypeXPS - "XPS" - XPS Document (.xps).

The following arguments are optional

Filename (String) - A string that indicates the name of the file to be saved. You can include a full path, or Excel saves the file in the current folder.

Quality (XlFixedFormatQuality) - Can be set to either of the following XlFixedFormatQuality constants: xlQualityStandard or xlQualityMinimum.

Possible Values are xlQualityMinimum - Minimum quality, xlQualityStandard - Standard quality.

IncludeDocProperties (Boolean) - Set to True to indicate that document properties should be included, or set to False to indicate that they are omitted.

IgnorePrintAreas (Boolean) - If set to True, ignores any print areas set when publishing. If set to False, uses the print areas set when publishing.

From (Long) - The number of the page at which to start publishing. If this argument is omitted, publishing starts at the beginning.

To (Long) - The number of the last page to publish. If this argument is omitted, publishing ends with the last page.

OpenAfterPublish - If set to True, displays the file in the viewer after it is published. If set to False, the file is published but not displayed

FixedFormatExtClassPtr - Pointer to the FixedFormatExt class

WorkIdentity

XmlImport

Imports an XML data file into the current workbook.

Possible Values are 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.

This method allows you to import data into the workbook from a file path. Excel uses the first qualifying map found, or if the destination range is specified, Excel automatically lists the data. Don't specify a value for the Destination parameter if you want to import data into an existing mapping. The following conditions cause the XmlImport method to generate run-time errors:

XmlImport (Url, ImportMap, Overwrite, Destination)

Dim strUrl As String: strUrl = 
Dim xxiXmlImport As XlXmlImportResult
xxiXmlImport = ActiveWorkbook.XmlImport(Url:=strUrl, ImportMap:=)

Arguments

The following arguments are required:

Url (String) - A uniform resource locator (URL) or a uniform naming convention (UNC) path to an XML data file.

ImportMap (XmlMap) - The schema map to apply when importing the file. If the data was previously imported, contains a reference to the XmlMap object containing the data.

The following arguments are optional

Overwrite (Boolean) - If a value is not specified for the Destination parameter, this parameter specifies whether 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, this parameter specifies whether 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 (Range) - Specifies the range where the list will be created. You only use the top-left corner of the range.

XmlImportXml

Imports an XML data stream that has been previously loaded into memory. Excel uses the first qualifying map found, or if the destination range is specified, Excel automatically lists the data.

Possible Values are 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.

Don't specify a value for the Destination parameter if you want to import data into an existing mapping. The following conditions cause the XmlImport method to generate run-time errors:

XmlImportXml (Data, ImportMap, Overwrite, Destination)

Dim strData As String: strData = 
Dim xxiXmlImportXml As XlXmlImportResult
xxiXmlImportXml = ActiveWorkbook.XmlImportXml(Data:=strData, ImportMap:=)

Arguments

The following arguments are required:

Data (String) - The data to import.

ImportMap (XmlMap) - The schema map to apply when importing the file.

The following arguments are optional

Overwrite (Boolean) - If a value is not specified for the Destination parameter, this parameter specifies whether 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, this parameter specifies whether 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 (Range) - Specifies the range where the list will be created. Excel only uses the top-left corner of the range.