How to: Remove Data from the Data Store When Deleting a Content Control
Word Developer Reference |
You can delete a content control by calling the Delete method of the ContentControl object. For example, the following code deletes the content control with the title "MyTitle".
|
You can also delete a single node by calling the Delete method of the CustomDataXMLNode object that you want to remove. You can delete an entire custom XML part by calling the Delete method of the CustomXMLPart object that you want to remove.
For more information about content controls, see Working with Content Controls.
The objects used in these samples are:
- ContentControl
- ContentControls
- CustomXMLPart (2007 Microsoft Office system core object model)
- CustomXMLParts (2007 Microsoft Office system core object model)
- XMLMapping
Sample 1
The first code sample creates a content control and sets an XML mapping on a content control.
Build a valid custom XML file, save it to your hard disk drive, and add a data store to the document that contains the information you want to map to.
Suppose the content control is mapped to the following sample custom XML file.
|
Now, suppose the content control is mapped to a <fruitType> node of the previous custom XML part.
|
Sample 2
The second code sample removes the entire CustomXMLPart object when the content control is deleted.
|