ControlCollection.AddContentControl Method (, String) (2007 System)

Adds a new ContentControl that is based on a native content control 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 ( _
    contentControl As ContentControl, _
    name As String _
) As ContentControl
'Usage
Dim instance As ControlCollection 
Dim contentControl As ContentControl 
Dim name As String 
Dim returnValue As ContentControl 

returnValue = instance.AddContentControl(contentControl, _
    name)
public ContentControl AddContentControl(
    ContentControl contentControl,
    string name
)
public:
ContentControl^ AddContentControl(
    ContentControl^ contentControl, 
    String^ name
)
public function AddContentControl(
    contentControl : ContentControl, 
    name : String
) : ContentControl

Parameters

  • contentControl
    Type: ContentControl

    The Microsoft.Office.Interop.Word.ContentControl that is the basis for the new control.

Return Value

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

Exceptions

Exception Condition
ArgumentNullException

contentControl is nulla null reference (Nothing in Visual Basic).

-or-

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.

ArgumentException

contentControl is not a building block gallery (that is, the Microsoft.Office.Interop.Word.ContentControl.Type property of contentControl does not have the value Microsoft.Office.Interop.Word.WdContentControlType.wdContentControlRichText).

Remarks

Use this method to add a new ContentControl that is based on a native content control in the document at run time. This is useful when you create a ContentControl at run time, and you want to recreate the same control the next time the document is opened. For more information, see Adding Controls to Office Documents at Run Time.

.NET Framework Security

See Also

Reference

ControlCollection Class

ControlCollection Members

AddContentControl Overload

Microsoft.Office.Tools.Word Namespace