Sub CreateXMLList()
Dim oMyMap As XmlMap
Dim strXPath As String
Dim oMyList As ListObject
Dim oMyNewColumn As ListColumn
ThisWorkbook.XmlMaps.Add (ThisWorkbook.Path & "\Myschema.xsd")
Set oMyMap = ThisWorkbook.XmlMaps("EmployeeSales_Map")
Range("A1").Select
Set oMyList = ActiveSheet.ListObjects.Add
strXPath = "/EmployeeSales/Employee/Empid"
oMyList.ListColumns(1).XPath.SetValue oMyMap, strXPath
Set oMyNewColumn = oMyList.ListColumns.Add
strXPath = "/EmployeeSales/Employee/InvoiceNumber"
oMyNewColumn.XPath.SetValue oMyMap, strXPath
Set oMyNewColumn = oMyList.ListColumns.Add
strXPath = "/EmployeeSales/Employee/InvoiceAmount"
oMyNewColumn.XPath.SetValue oMyMap, strXPath
oMyList.ListColumns(1).Name = "EmployeeId"
oMyList.ListColumns(2).Name = "Invoice Number"
oMyList.ListColumns(3).Name = "Invoice Amount"
End Sub
|