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

Jim DeMarco

"Pro Excel 2007 VBA"

XmlImport Function Argument Descriptions
Name Required (Y/N) Data Type Description
URL Y String Path to an XML data file.
ImportMap Y XMLMap The XML map to apply when importing the
file.
Overwrite N Variant Specifies whether or not to overwrite data
that has been mapped to the schema map
specified in the ImportMap parameter. Set to
True to overwrite the data or False to append
the new data to the existing data.
Destination N Variant Specifies the top-left cell of the range that will
display the data.
The XmlImport function returns a value of type XIXmlImportResult, which is an enum
showing the success or failure of the call. Figure 3-6 shows the available options displayed in
the Object Browser window.
Figure 3-6. XIXmlImportResult members
Let??™s run our GetXMLData procedure and see what we get.
If no schema exists for this data, Excel will create one for you, as shown in Figure 3-7.
Figure 3-7. XML Schema dialog box
Excel refers to these schemas as XML maps. Click the check box so you won??™t see this
message any longer, and let the import continue. When the import is finished, the data should
look like that in Figure 3-8.
CHAPTER 3 n USING XML IN EXCEL 2007 102
Figure 3-8. Imported XML file
Our call to XmlImport sets the arguments like this:
ActiveWorkbook.XmlImport URL:= _
"C:\projects\Excel\cds.xml", ImportMap:= ??
Nothing, Overwrite:=True, Destination:=Range("$A$1")
The URL argument is pointing to a file named cds.xml, which contains discography information.


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