SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 114 | Next

Jim DeMarco

"Pro Excel 2007 VBA"


The ImportMap argument is set to Nothing for now because we do not have an existing
schema for this data. We are setting Overwrite to True to overwrite any existing data, and the
Destination range is setting cell A1 as the target for the start of our data range.
If we try to rerun this code as is, we will generate an error, as shown in Figure 3-9.
Figure 3-9. XML map error
This is due to the fact that the first time we ran the code, Excel created a map for us and
bound our data table to it. To view that map, right-click anywhere in the data range and
choose XML ?ยค XML Source (Figures 3-10 and 3-11).
CHAPTER 3 n USING XML IN EXCEL 2007 103
Figure 3-10. XML menu
Figure 3-11. The XML Source window
CHAPTER 3 n USING XML IN EXCEL 2007 104
Figure 3-11 shows the XML Source window with the artist element selected. Selecting an
element in the XML Source window selects the associated (or mapped) data range. Above the
XML map is a drop-down list that contains all of the XML maps in the currently active workbook.
The XML map in this project is called cds_Map.
The second time the code is run, we run into trouble because Excel automatically creates
a new map for the data that is mapped to destination cell A1. Excel will not allow you to bind
your data to more than one XML map. If you change the destination cell, the procedure runs
fine, however. So how do we refresh our data if a source file is updated?
The XMLMaps collection has a DataBinding property that has a Refresh method.


Pages:
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126