ContentControls.Add(WdContentControlType, Object) 方法

定义

将指定类型的新内容控件添加到活动文档中,并返回 ContentControl 表示新内容控件的对象。Adds a new content control, of the type specified, into the active document and returns a ContentControl object that represents the new content control.

public Microsoft.Office.Interop.Word.ContentControl Add (Microsoft.Office.Interop.Word.WdContentControlType Type = Microsoft.Office.Interop.Word.WdContentControlType.wdContentControlRichText, ref object Range);
abstract member Add : Microsoft.Office.Interop.Word.WdContentControlType * obj -> Microsoft.Office.Interop.Word.ContentControl
Public Function Add (Optional Type As WdContentControlType = Microsoft.Office.Interop.Word.WdContentControlType.wdContentControlRichText, Optional ByRef Range As Object) As ContentControl

参数

Type
WdContentControlType

指定要插入活动文档中的内容控件的类型。Specifies the type of content control to insert into the active document. 如果省略,Microsoft Office Word 插入一个 rtf 内容控件。If omitted, Microsoft Office Word inserts a rich-text content control.

Range
Object

指定内容控件在活动文档中的放置位置。如果省略它,Word 会将内容控件放在插入点所在位置,或者替换当前所选内容。Specifies where in the active document to place the content control. If omitted, Word places the content control at the position of the insertion point or replaces the current selection.

返回

ContentControl

ContentControl

注解

只能在 RTF 内容控件、生成块库内容控件和组内容控件中嵌套内容控件。You can nest content controls only within rich-text content controls, building block gallery content controls, and group content controls. 如果插入点或当前所选项在不同类型的内容控件的内部,则此方法将引发错误。If the insertion point or current selection is inside a content control of a different type, this method raises an error. 在这种情况下,您可以移动插入点,也可以使用 Range 参数指定文档中的位置。In this case, you can either move the insertion point or use the Range parameter to specify a location within the document.

适用于