ExportXML Method [Access 2003 VBA Language Reference]
The ExportXML method allows developers to export XML data, schemas, and presentation information from Microsoft SQL Server 2000 Desktop Engine (MSDE 2000), Microsoft SQL Server 6.5 or later, or the Microsoft Jet database engine.
expression.ExportXML(ObjectType, DataSource, DataTarget, SchemaTarget, PresentationTarget, ImageTarget, Encoding, OtherFlags, WhereCondition, AdditionalData**)**
expression Required. An expression that returns an Application object.
AcExportXMLObjectType
AcExportXMLObjectType can be one of these AcExportXMLObjectType constants: |
acExportForm |
acExportFunction |
acExportQuery |
acExportReport |
acExportServerView |
acExportStoredProcedure |
acExportTable |
DataSource Required String. The name of the AccessObject object to export. The default is the currently open object of the type specified by the ObjectType argument.
DataTarget Optional String. The file name and path for the exported data. If this argument is omitted, data is not exported.
SchemaTarget Optional String. The file name and path for the exported schema information. If this argument is omitted, schema information is not exported to a separate XML file.
PresentationTarget Optional String. The file name and path for the exported presentation information. If this argument is omitted, presentation information is not exported.
ImageTarget Optional String. The path for exported images. If this argument is omitted, images are not exported.
AcExportXMLEncoding
AcExportXMLEncoding can be one of these AcExportXMLEncoding constants: |
acUTF16 |
acUTF8default |
AcExportXMLOtherFlags
AcExportXMLOtherFlags can be one of these AcExportXMLOtherFlags constants: |
acEmbedSchema Writes schema information into the document specified by the DataTarget argument; this value takes precedence over the SchemaTarget argument. |
acExcludePrimaryKeyAndIndexes Does not export primary key and index schema properties. |
acLiveReportSource Creates a live link to a remote Microsoft SQL Server 2000 database. Valid only when you are exporting reports that are bound to a Microsoft SQL Server 2000 database. |
acPersistReportML Persists the exported object's ReportML information. |
acRunFromServer Creates an Active Server Pages (ASP) wrapper; otherwise, default is an HTML wrapper. Applies only when you are exporting reports. |
WhereCondition Optional String. Specifies a subset of records to be exported.
AdditionalData Optional AdditionalData. Specifies additional tables to export. This argument is ignored if the OtherFlags argument is set to acLiveReportSource.
Remarks
Although the DataTarget, SchemaTarget, and PresentationTarget arguments are all optional, at least one must be specified when you are using this method. When the ExportXML method is called from within an AccessObject object, the default behavior is to overwrite any existing files specified in any of the arguments.
Example
The following example exports the contents of the Customers table in the Northwind Traders sample database, along with the contents of the Orders and Orders Details tables, to an XML data file named Customer Orders.xml.
Sub ExportCustomerOrderData()
Dim objOrderInfo As AdditionalData
Dim objOrderDetailsInfo As AdditionalData
Set objOrderInfo = Application.CreateAdditionalData
' Add the Orders and Order Details tables to the data to be exported.
Set objOrderDetailsInfo = objOrderInfo.Add("Orders")
objOrderDetailsInfo.Add "Order Details"
' Export the contents of the Customers table. The Orders and Order
' Details tables will be included in the XML file.
Application.ExportXML ObjectType:=acExportTable, DataSource:="Customers", _
DataTarget:="Customer Orders.xml", _
AdditionalData:=objOrderInfo
End Sub
The following example exports the table named Customers in the current database to an XML file; the data and schema are exported as separate files.
Application.ExportXML _
ObjectType:=acExportTable, _
DataSource:="Customers", _
DataTarget:="Customers.xml", _
SchemaTarget:="CustomersSchema.xml"
The following example exports the report called Fall2000 in the current database to an XML file. Presentation information is also exported, and images are placed in the specified directory. The report is exported with an ASP wrapper rather than the default HTML wrapper.
Application.ExportXML _
ObjectType:=acExportReport, _
DataSource:="Fall2000", _
DataTarget:="Fall2000.xml", _
PresentationTarget:="Fall2000Report.xsl", _
ImageTarget:="Images", _
OtherFlags:=acRunFromServer
Applies to | Application Object
See Also | ImportXML Method