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 121 | Next

Jim DeMarco

"Pro Excel 2007 VBA"

XmlMaps(ActiveWorkbook.XmlMaps.Count).Name
End Function
We are making the same call to the XmlImport method of the ActiveWorkbook object as
we did in the examples that we created in standard code modules??”but rather than directly
setting its arguments, we are referring to the internal variables of our cXML class.
The GetNewXMLData method is actually doing two jobs for us. The first, of course, is getting
the data into our worksheet. Remember that a call to the XmlImport method brings in
data and creates an XML map. The second line of code in this method is setting our class??™s
MapName property for us:
m_sMapName = ActiveWorkbook.XmlMaps(ActiveWorkbook.XmlMaps.Count).Name
This will come in handy when we need to add data or overwrite the current set of data.
By checking the XmlMaps.Count property, we can get the latest addition to the collection that
was added by the XmlImport method.
Now we??™ll add a second private function that will append or overwrite data for an existing
XML map. Add a new private function and name it GetXMLForExistingMap. Add the following
code:
Private Function GetXMLForExistingMap(DoOverwrite As Boolean)
ActiveWorkbook.XmlMaps(m_sMapName).Import m_sXMLSourceFile, DoOverwrite
End Function
This function takes one argument, which is used to flag whether we want to append or
overwrite our existing data. The single line of code should again be familiar.We are using the
XmlMaps collection??™s Import method to get our data. Notice that we??™re using the internal
m_sMapName variable to determine which XML map the data corresponds to.


Pages:
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133