Microsoft Office Tutorials and References
In Depth Information
Note You don’t need to map every element of a schema to a worksheet for the data
import to work correctly.
Adding XML to a Worksheet Programmatically
As you might expect, every XML-related action you can take using the Excel interface has its
counterpart in the Excel object, although there are times when you have to dig a bit to find
out how to do something in VBA that takes a simple and intuitive action when going through
the interface. One example of that phenomenon is the series of actions you need to take to
create a single data list (rather than a series of lists) from an XML schema.
Mapping a Schema to a Worksheet Programmatically
When you map an XML schema to a worksheet in VBA, you do so by creating a variable that
contains a reference to an XmlMap object, which is the object used to represent a schema
contained in an .xsd file. Table 26-3 lists the XmlMap object’s properties and methods.
Table 26-3. Selected Properties and Methods of the
XmlMap Object
Property or Method
Description
Property
AdjustColumnWidth
A Boolean value that, when set to True (the default),
causes Excel to change the column width to fit the
data imported into that column. Setting the property
to False causes the columns to retain their width at
the time of the import.
AppendOnImport
A Boolean value that, when set to False (the
default), causes data imported into a schema to
overwrite the existing values. Setting this property to
True causes newly imported data to be appended to
an existing list.
IsExportable
A Boolean value that returns True if Excel can use
the XPath objects in the specified schema map to
export XML data and if all XML lists mapped to the
specified schema map can be exported.
Name
A string that contains the name of an XML map. The
string must be unique within the workbook and
cannot exceed 255 characters.
PreserveColumnFilter
A Boolean value that, when set to True (the default),
causes any list filter to be retained when the map is
refreshed.
continued
Search JabSto ::




Custom Search