|Word Developer Reference|
expression.SetMapping(XPath, PrefixMapping, Source)
expression An expression that returns an XMLMapping object.
|XPath||Required||String||Specifies an XPath string that represents the XML node to which to map the content control. An invalid XPath string causes a run-time error.|
|PrefixMapping||Optional||String||Specifies the prefix mappings to use when querying the expression provided in the XPath parameter. If omitted, Word uses the set of prefix mappings for the specified custom XML part in the current document.|
|Source||Optional||CustomXMLPart||Specifies the desired custom XML data to which to map the content control. If this parameter is omitted, the XPath is evaluated against all custom XML in the current document, and the mapping is established with the first CustomXMLPart in which the XPath resolves to an XML node.|
If the XML mapping already exists, Word replaces the existing XML mapping and the contents of the new mapped XML node replaces the text of the content control. If the specified XPath does not evaluate to an XML node in the specified custom XML part or parts, you can still specify the mapping, and one will be created. This mapping automatically links when the specified XPath would evaluate to an XML node in the specified custom XML parts.
See also the SetMappingByNode method.
|Creating a mapping for a rich-text content control causes a run-time error.|
The following example inserts a custom XML part and sets the XML for the custom part, and then inserts two content controls at the beginning of the document and maps the contents of the controls to the contents of XML elements in the custom part.
|Visual Basic for Applications|
- XMLMapping Object
- XMLMapping Object Members
- How to: Bind a Content Control to a Node in the Data Store
- How to: Bind Controls to a Specific Row in the Data Store When Inserting a Building Block
- How to: Capture and Respond to Events in the Data Store
- Walkthrough: Connect an Item in the Data Store to a SQL Server Database
- Walkthrough: Connect an Item in the Data Store to a Web Service
- Walkthrough: Connect an Item in the Data Store to an Access Database
- Walkthrough: Connect an Item in the Data Store to an Excel Workbook
- Working with Content Controls