A family of Microsoft word processing software products for creating web, email, and print documents.
David,
Microsoft's XML Mapping is basic at best. Using their interface, you can’t remove items. You can certainly do it with VBA. Here I have a procedure that adds thee copies of an identical XML Part. Then three methods to remove them:
Sub AddIdenticalParts()
'A basic Word macro coded by Greg Maxey
Dim lngIndex As Long
For lngIndex = 1 To 3
ActiveDocument.CustomXMLParts.Add "<?xml version='1.0'?><CC_Map_Root xmlns='http://TheAnchorage.com'>" _
& "<mapNode_1></mapNode_1><mapNode_2></mapNode_2><mapNode_3></mapNode_3><mapParentNode_1>" _
& "<nestedMapNode_1></nestedMapNode_1><nestedMapNode_2></nestedMapNode_2>" _
& "</mapParentNode_1></CC_Map_Root>"
Next lngIndex
lbl_Exit:
Exit Sub
End Sub
Sub RemoveWithOutMercyAllNonBuiltInCXPsExceptFirst()
Dim lngIndex As Long
For lngIndex = ActiveDocument.CustomXMLParts.Count To 4 Step -1
ActiveDocument.CustomXMLParts(lngIndex).Delete
Next lngIndex
lbl_Exit:
Exit Sub
End Sub
Sub RemoveDuplicatedNamespaces()
Dim lngIndex As Long
Dim oCXP As CustomXMLPart
Dim oCol As New Collection
For lngIndex = ActiveDocument.CustomXMLParts.Count To 3 Step -1
Set oCXP = ActiveDocument.CustomXMLParts(lngIndex)
On Error Resume Next
oCol.Add oCXP.NamespaceURI, oCXP.NamespaceURI
If Err.Number <> 0 Then
oCXP.Delete
Err.Clear
End If
Next lngIndex
lbl_Exit:
Exit Sub
End Sub
Sub RemoveDuplicatedTargetedNamespaces()
Dim lngIndex As Long
Dim oCXP As CustomXMLPart
Dim oCol As New Collection
Do
On Error GoTo Err_Limit
lngIndex = lngIndex + 1
Set oCXP = ActiveDocument.CustomXMLParts.SelectByNamespace("http://TheAnchorage.com").Item(lngIndex)
oCol.Add oCXP, CStr(lngIndex)
Loop
Process:
For lngIndex = oCol.Count To 2 Step -1
oCol.Item(lngIndex).Delete
Next
lbl_Exit:
Exit Sub
Err_Limit:
Resume Process
End Sub
Or you could use the Advanced Mapping features of my CC Tools Add-In:
https://gregmaxey.com/word\_tip\_pages/content\_control\_tools.html