XMLMapping.XPath Property (Word)
Returns a String that represents the XPath for the XML mapping, which evaluates to the currently mapped XML node. Read-only.
Syntax
expression .XPath
expression An expression that returns an XMLMapping object.
Remarks
To set mapping for a content control, use the SetMapping method or the SetMappingByNode method. If the mapping is not active, using this property returns an error.
Example
The following example checks whether the first content control in the active document is a date control and whether the XPath string is set to a specific built-in document property. It then sets the mapping to the control, if the XPath does not match and the control is a date control.
Dim objCC As ContentControl
Dim objMap As XMLMapping
Dim blnMap As Boolean
Set objCC = ActiveDocument.ContentControls(1)
Set objMap = objCC.XMLMapping
If (objCC.Type = wdContentControlDate) And (objMap.XPath <> _
"/ns1:coreProperties[1]/ns0:createdate[1]") Then
blnMap = objMap.SetMapping(XPath:="/ns1:coreProperties[1]/ns0:createdate[1]")
If blnMap = False Then
MsgBox "Unable to map the content control."
End If
End If