语言

ControlCollection.AddContentControl 方法

定义

重载

名称 说明
AddContentControl(ContentControl, String)

添加一个新的 ContentControl,它基于文档中的本机内容控件。

AddContentControl(String, WdContentControlType)

将一个指定类型的新 ContentControl 添加到文档中当前选定的位置。

AddContentControl(Range, String, WdContentControlType)

将一个指定类型的新 ContentControl 添加到文档中的指定范围。

AddContentControl(ContentControl, String)

添加一个新的 ContentControl,它基于文档中的本机内容控件。

public:
 Microsoft::Office::Tools::Word::ContentControl ^ AddContentControl(Microsoft::Office::Interop::Word::ContentControl ^ contentControl, System::String ^ name);
public Microsoft.Office.Tools.Word.ContentControl AddContentControl(Microsoft.Office.Interop.Word.ContentControl contentControl, string name);
abstract member AddContentControl : Microsoft.Office.Interop.Word.ContentControl * string -> Microsoft.Office.Tools.Word.ContentControl
Public Function AddContentControl (contentControl As ContentControl, name As String) As ContentControl

参数

contentControl
ContentControl

一个 Microsoft.Office.Interop.Word.ContentControl,它是新控件的基础。

name
String

新控件的名称。

返回

ContentControl,已添加到该文档。

例外

contentControl 为 null.-或- name is null 或 具有零长度。

ControlCollection 中已存在具有相同名称的控件。

contentControl不是构建基块库 (即 Microsoft.Office.Interop。Word。的 contentControl ContentControl.Type 属性没有值 Microsoft.Office.Interop.Word。WdContentControlType.wdContentControlRichText) 。

注解

使用此方法在运行时添加基于文档中本机内容控件的新 ContentControl 。 如果在运行时创建 , ContentControl 并且希望在下次打开文档时重新创建同一控件,这非常有用。 有关详细信息,请参阅 Adding Controls to Office Documents at Run Time。

适用于

AddContentControl(String, WdContentControlType)

将一个指定类型的新 ContentControl 添加到文档中当前选定的位置。

public:
 Microsoft::Office::Tools::Word::ContentControl ^ AddContentControl(System::String ^ name, Microsoft::Office::Interop::Word::WdContentControlType contentControlType);
public Microsoft.Office.Tools.Word.ContentControl AddContentControl(string name, Microsoft.Office.Interop.Word.WdContentControlType contentControlType);
abstract member AddContentControl : string * Microsoft.Office.Interop.Word.WdContentControlType -> Microsoft.Office.Tools.Word.ContentControl
Public Function AddContentControl (name As String, contentControlType As WdContentControlType) As ContentControl

参数

name
String

新控件的名称。

contentControlType
WdContentControlType

Microsoft.Office.Interop.Word.WdContentControlType 值之一,指定新内容控件的基础类型。

返回

ContentControl,已添加到该文档。

例外

name 为 null,或其长度为零。

ControlCollection 中已存在具有相同名称的控件。

注解

使用此方法在运行时在文档中的当前选定内容处添加新 ContentControl 的 。 有关详细信息,请参阅 Adding Controls to Office Documents at Run Time。

适用于

AddContentControl(Range, String, WdContentControlType)

将一个指定类型的新 ContentControl 添加到文档中的指定范围。

public:
 Microsoft::Office::Tools::Word::ContentControl ^ AddContentControl(Microsoft::Office::Interop::Word::Range ^ range, System::String ^ name, Microsoft::Office::Interop::Word::WdContentControlType contentControlType);
public Microsoft.Office.Tools.Word.ContentControl AddContentControl(Microsoft.Office.Interop.Word.Range range, string name, Microsoft.Office.Interop.Word.WdContentControlType contentControlType);
abstract member AddContentControl : Microsoft.Office.Interop.Word.Range * string * Microsoft.Office.Interop.Word.WdContentControlType -> Microsoft.Office.Tools.Word.ContentControl
Public Function AddContentControl (range As Range, name As String, contentControlType As WdContentControlType) As ContentControl

参数

range
Range

Range,可为新控件提供边界。

name
String

新控件的名称。

contentControlType
WdContentControlType

Microsoft.Office.Interop.Word.WdContentControlType 值之一,指定新内容控件的基础类型。

返回

ContentControl,已添加到该文档。

例外

name 为 null,或其长度为零。

ControlCollection 中已存在具有相同名称的控件。

注解

使用此方法在运行时在文档中的指定区域添加新 ContentControl 的 。 有关详细信息,请参阅 Adding Controls to Office Documents at Run Time。

适用于