Associating XML Elements with Ranges
Sub MapRanges() Dim xmMap As XmlMap Dim ws As Worksheet Dim sPath As String Dim loList As ListObject Set ws = ThisWorkbook.Worksheets("Invoice") Set xmMap = ThisWorkbook.XmlMaps("Invoice_Map") Application.DisplayAlerts = False sPath = "/Invoice/Customer/CustomerName" MapRange ws.Range("CustomerName"), xmMap, sPath Application.DisplayAlerts = True Set xmMap = Nothing Set ws = Nothing Set loList = Nothing End Sub Function MapRange(rg As Range, xmMap As XmlMap, sPath As String) _ As Boolean On Error GoTo ErrHandler If rg.XPath.Value = "" Then rg.XPath.SetValue xmMap, sPath Else rg.XPath.Clear rg.XPath.SetValue xmMap, sPath End If MapRange = True Exit Function ErrHandler: MapRange = True End Function
1. | Map Repeating Range |