ControlCollection.AddContentControl Method (, String, ) (2007 System)
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.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)
Syntax
'Declaration
Public Function AddContentControl ( _
range As Range, _
name As String, _
contentControlType As WdContentControlType _
) As ContentControl
'Usage
Dim instance As ControlCollection
Dim range As Range
Dim name As String
Dim contentControlType As WdContentControlType
Dim returnValue As ContentControl
returnValue = instance.AddContentControl(range, _
name, contentControlType)
public ContentControl AddContentControl(
Range range,
string name,
WdContentControlType contentControlType
)
public:
ContentControl^ AddContentControl(
Range^ range,
String^ name,
WdContentControlType contentControlType
)
public function AddContentControl(
range : Range,
name : String,
contentControlType : WdContentControlType
) : ContentControl
Parameters
range
Type: RangeA Range that provides the bounds for the new control.
name
Type: System.StringThe name of the new control.
contentControlType
Type: WdContentControlTypeOne of the Microsoft.Office.Interop.Word.WdContentControlType values that specifies the underlying type of the new content control.
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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.