Microsoft Office Tutorials and References
In Depth Information
On Error Resume Next
xDataFile = “C:\MySuppliers.xml"
Set myMap = ActiveWorkbook.XmlMaps(“Root_Map”)
strXPath = “/Root/Supplier/SupplierID"
Range(“B2:B10”).XPath.SetValue myMap, strXPath
Range(“B2”).Value = “Supplier ID"
strXPath = “/Root/Supplier/CompanyName"
Range(“C2:C10”).XPath.SetValue myMap, strXPath
Range(“C2”).Value = “Company Name"
strXPath = “/Root/Supplier/ContactName"
Range(“D2:D10”).XPath.SetValue myMap, strXPath
Range(“D2”).Value = “Contact Name"
strXPath = “/Root/Supplier/ContactTitle"
Range(“E2:E10”).XPath.SetValue myMap, strXPath
Range(“E2”).Value = “Contact Title"
strXPath = “/Root/Supplier/MailingAddress/Address"
Range(“F2:F10”).XPath.SetValue myMap, strXPath
Range(“F2”).Value = “Address"
strXPath = “/Root/Supplier/MailingAddress/City"
Range(“G2:G10”).XPath.SetValue myMap, strXPath
Range(“G2”).Value = “City"
strXPath = “/Root/Supplier/MailingAddress/Region"
Range(“H2:H10”).XPath.SetValue myMap, strXPath
Range(“H2”).Value = “Region"
strXPath = “/Root/Supplier/MailingAddress/PostalCode"
Range(“I2:I10”).XPath.SetValue myMap, strXPath
Range(“I2”).Value = “Postal Code"
strXPath = “/Root/Supplier/MailingAddress/Country"
Range(“J2:J10”).XPath.SetValue myMap, strXPath
Range(“J2”).Value = “Country"
strXPath = “/Root/Supplier/Phone"
Range(“K2:K10”).XPath.SetValue myMap, strXPath
Range(“K2”).Value = “Phone"
strXPath = “/Root/Supplier/Fax"
Range(“L2:L10”).XPath.SetValue myMap, strXPath
Range(“L2”).Value = “Fax"
ThisWorkbook.XmlMaps(“Root_Map”).Import xDataFile
If Err.Number = 0 Then
MsgBox “Data from “ & xDataFile & “ was imported into “ & _
“the “ & xMapName & “ map."
Else
MsgBox “There was a problem importing from “ & xDataFile
Exit Sub
End If
End Sub
Search JabSto ::




Custom Search