Program with XML Maps

The preceding sections explained how to use the new XML features found in Excel and provided code for saving, transforming, importing, and exporting XML with Excel. Those sections provide a context for Excel’s XML features and explain programming tasks that surround those features. The rest of this chapter deals exclusively with the XML objects Excel provides and offers specific examples of programming tasks you can perform with those objects, properties, and methods.

Excel’s XML object model deals exclusively with XML maps. Opening and saving XML spreadsheets is done through the Workbook object’s Open and Save methods. Figure 3-20 illustrates the Excel XML objects hierarchically.

The XML object hierarchy

Figure 3-20. The XML object hierarchy

The XmlMap object allows you to perform the following tasks in code:

  • Add XML maps to a workbook

  • Delete XML maps from a workbook

  • Export XML data through an XML map

  • Import XML data through an XML map

  • Bind an XML map to an XML data source

  • Refresh mapped lists and ranges from an XML data source

  • View the XML schema used by an XML map

The following sections explain these tasks in greater detail.

The XML Source task pane only gets you so far. By using code, you can create ways to update XML maps, change data bindings, and automate any other tasks that need automating.

How to add or delete XML maps

Use the XmlMaps collection to add ...

Get Excel 2003 Programming: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.