Condividi tramite


ControlCollection.AddContentControl Method (Range, String, WdContentControlType)

Adds a new ContentControl of the specified type at the specified range in the document.

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

Syntax

'Declaration
Function AddContentControl ( _
    range As Range, _
    name As String, _
    contentControlType As WdContentControlType _
) As ContentControl
ContentControl AddContentControl(
    Range range,
    string name,
    WdContentControlType contentControlType
)

Parameters

Return Value

Type: Microsoft.Office.Tools.Word.ContentControl
The ContentControl that was added to the document.

Exceptions

Exception Condition
ArgumentNullException

name is nulla null reference (Nothing in Visual Basic) or has zero length.

ControlNameAlreadyExistsException

A control with the same name is already in the ControlCollection.

Remarks

Use this method to add a new ContentControl at a specified range in the document at run time. For more information, see Adding Controls to Office Documents at Run Time.

.NET Framework Security

See Also

Reference

ControlCollection Interface

AddContentControl Overload

Microsoft.Office.Tools.Word Namespace