ContentControl Object
Word Developer Reference |
An individual content control. Content controls are bounded and potentially labeled regions in a document that serve as containers for specific types of content. Individual content controls may contain contents such as dates, lists, or paragraphs of formatted text. The ContentControl object is a member of the ContentControls collection.
Version Information
Version Added: Word 2007
Remarks
Use the Add method of the ContentControls collection to create a content control. Use the Type parameter of the Add method to specify the type of content control to create. The following example create a new drop-down list content control and adds several items to the list.
Visual Basic for Applications |
---|
|
Use the Type property to change the content control to a different type of content control. For example, perhaps you want to change from a date control to a text control. However, you may not be able to change all content controls to another type; some may not allow changing their type. In addition, depending on the contents of a content control, you may not be able to change the type. For example, if the content control that you want to change to does not allow the type of content that is in the existing content control, attempting to change the type is not allowed and generates a run-time error.
The following example inserts a date content control and sets the value of the control, and then changes the control to a text content control.
Visual Basic for Applications |
---|
|
Use the SetPlaceholderText method to change the placeholder text from the default string to something more appropriate for the control. Use the Title property to specify the title text for the control. This displays above the control when the cursor is positioned inside the control or the mouse pointer is positioned over the control.
Visual Basic for Applications |
---|
|
Depending on the type of content control that you have, you may not be able to use all the properties and methods of the ContentControl object.
Visual Basic for Applications |
---|
|
Not all content control properties apply to all the different types of content controls. The following table lists which properties apply to which types of content controls.
Property/Method | Applies To |
---|---|
BuildingBlockCategory property | BuildingBlock Gallery content controls (wdContentControlBuildingBlockGallery) |
BuildingBlockType property | BuildingBlock Gallery content controls (wdContentControlBuildingBlockGallery) |
DateDisplayFormat property | Date content controls (wdContentControlDate) |
DateDisplayLocale property | Date content controls (wdContentControlDate) |
DateStorageFormat property | Date content controls (wdContentControlDate) |
DropdownListEntries property | Combo box and drop-down list content controls (wdContentControlComboBox and wdContentControlDropdownList) |
MultiLine property | Plain text content controls (wdContentControlText) |
Ungroup method | Group content controls (wdContentControlGroup) |
See Also
- Word Object Model Reference
- ContentControl 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: Change a Content Control from One Type to Another
- How to: Change the Editability of a Content Control
- How to: Filter the Building Block List in a Content Control
- How to: Insert a Content Control into a Building Block
- How to: Remove Data from the Data Store When Deleting a Content Control
- How to: Set the Building Blocks That You Can Use for a Content Control
- 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