AutoTextEntry 方法(Word)AutoTextEntry.Insert method (Word)

插入自动图文集词条替换指定的范围。Inserts the AutoText entry in place of the specified range. 返回一个Range对象,该对象代表 "自动图文集" 词条。Returns a Range object that represents the AutoText entry.


表达式InsertWhereRichTextexpression.Insert (Where, RichText)

expression 是必需的。expression Required. 一个代表 "AutoTextEntry" 对象的变量。A variable that represents an 'AutoTextEntry' object.


名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
WhereWhere 必需Required RangeRange "自动图文集"词条的位置。The location for the AutoText entry.
RichTextRichText 可选Optional VariantVariant 要插入自动图文集词条时其原来的格式。True to insert the AutoText entry with its original formatting.

返回值Return value



如果您不想替换该范围,请使用本方法之前使用 Collapse 方法。If you don't want to replace the range, use the Collapse method before using this method.


本示例在选定内容的后面插入带格式的“自动图文集”词条“one”。This example inserts the formatted AutoText entry named "one" after the selection.

Sub InsertAutoTextEntry() 
 Selection.Collapse Direction:=wdCollapseEnd 
 ActiveDocument.AttachedTemplate.AutoTextEntries("one").Insert _ 
 Where:=Selection.Range, RichText:=True 
End Sub

另请参阅See also

AutoTextEntry 对象AutoTextEntry Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.