Importing an XML Data File : Worksheet Export Import « Excel « VBA / Excel / Access / Word






Importing an XML Data File

 
Sub ImportXMLData() 
    Dim xlImportResult As XlXmlImportResult 

    xlImportResult = ThisWorkbook.XmlMaps("Invoice_Map").Import("C:\invoice.xml", True) 

    Select Case xlImportResult 
        Case xlXmlImportElementsTruncated 
            Debug.Print "XML data items imported with truncation." 
        Case xlXmlImportSuccess 
            Debug.Print "XML data items imported successfully." 
        Case xlXmlImportValidationFailed 
            Debug.Print "XML data items not imported. Validation failed." 
        Case Else 
            Debug.Print "Data import process reported an unknown result code." 
    End Select 

    Set xlImportResult = Nothing 
End Sub 

 








Related examples in the same category

1.Exporting XML
2.Adding a Schema to a Workbook