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

例外狀況

contentControlnull.-或- namenull 或 長度為零。

ControlCollection 中已具有相同名稱的控制項。

contentControl不是 (即 Microsoft.Office.Interop 的建置組塊庫。Word。的 ContentControl.Type 屬性contentControl沒有值 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

例外狀況

namenull 或長度為 0。

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

例外狀況

namenull 或長度為 0。

ControlCollection 中已具有相同名稱的控制項。

備註

使用這個方法,在執行時間於檔案中的指定範圍新增新的 ContentControl 。 如需詳細資訊,請參閱 Adding Controls to Office Documents at Run Time

適用於