更新:2007 年 11 月
将一个指定类型的新 ContentControl 添加到文档中当前选定的位置。
命名空间:  Microsoft.Office.Tools.Word
程序集:  Microsoft.Office.Tools.Word.v9.0(在 Microsoft.Office.Tools.Word.v9.0.dll 中)
语法
声明
Public Function AddContentControl ( _
    name As String, _
    contentControlType As WdContentControlType _
) As ContentControl
用法
Dim instance As ControlCollection
Dim name As String
Dim contentControlType As WdContentControlType
Dim returnValue As ContentControl
returnValue = instance.AddContentControl(name, _
    contentControlType)
public ContentControl AddContentControl(
    string name,
    WdContentControlType contentControlType
)
参数
- name 
 类型:System.String- 新控件的名称。 
- contentControlType 
 类型:Microsoft.Office.Interop.Word.WdContentControlType- Microsoft.Office.Interop.Word.WdContentControlType 值之一,指定新内容控件的基础类型。 
返回值
类型:Microsoft.Office.Tools.Word.ContentControl
添加到文档的 ContentControl。
异常
| 异常 | 条件 | 
|---|---|
| ArgumentNullException | name 为 nullnull 引用(在 Visual Basic 中为 Nothing) 或长度为零。 | 
| ControlNameAlreadyExistsException | ControlCollection 中已存在一个同名控件。 | 
备注
使用此方法可在运行时在文档中的当前选定位置添加一个新的 ContentControl。有关更多信息,请参见在运行时向 Office 文档添加控件。
权限
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。