Name
workbook.XmlImport(Url, ImportMap, [Overwrite], [Destination])
Synopsis
Imports an XML file into a list in the workbook. Returns an xlXMLImportResult value indicating whether the import succeeded.
|
Argument |
Settings |
|---|---|
|
|
The address of the XML file to import. The file may be stored on the local machine or at a network address. |
|
|
An |
|
|
True overwrites any data previously imported through the XML map; False appends data. Default is True. |
|
|
A |
The ImportMap argument is required, but it doesn’t have to be initialized, since XmlImport creates the XML map if none exists. For example, the following code imports an XML file into a new worksheet and creates the XML map based on the XML source file:
Dim ws As Worksheet, xmap As XmlMap, msg As String
' Create a new worksheet for the imported data.
Set ws = ThisWorkbook.Worksheets.Add
ret = ThisWorkbook.XmlImport( _
"http://www.mstrainingkits.com/excel/ExcelObjects.xml", _
xmap, , ws.Range("A1"))
Select Case ret
Case XlXmlImportResult.xlXmlImportElementsTruncated
msg = "Data was truncated."
Case XlXmlImportResult.xlXmlImportSuccess
msg = "XML data imported successfully."
Case XlXmlImportResult.xlXmlImportValidationFailed
msg = "XML was not valid."
End Select
MsgBox msgThe return value of XmlImport ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access