Share via


XMLMapping.XPath Property

Returns a String that represents the XPath for the XML mapping, which evaluates to the currently mapped XML node. Read-only.

Namespace:  Microsoft.Office.Interop.Word
Assembly:  Microsoft.Office.Interop.Word (in Microsoft.Office.Interop.Word.dll)

Syntax

'Declaration
ReadOnly Property XPath As String
    Get
'Usage
Dim instance As XMLMapping
Dim value As String

value = instance.XPath
string XPath { get; }

Property Value

Type: System.String

Remarks

To set mapping for a content control, use the SetMapping(String, String, CustomXMLPart) method or the SetMappingByNode(CustomXMLNode) method. If the mapping is not active, using this property returns an error.

Examples

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 IfEnd If

See Also

Reference

XMLMapping Interface

XMLMapping Members

Microsoft.Office.Interop.Word Namespace