将文本插入文档

   

使用 InsertAfterInsertBefore 方法在 SelectionRange 对象之前或之后插入文字。下列示例在活动文档的末尾插入文字。

Sub InsertTextAtEndOfDocument()
    ActiveDocument.Content.InsertAfter Text:=" The end."
End Sub

下列示例在所选内容之前插入文字。

Sub AddTextBeforeSelection()
    Selection.InsertBefore Text:="new text "
End Sub

Range 对象或 Selection 对象在使用了 InsertBeforeInsertAfter 方法之后,会扩展并包含新的文本。使用 Collapse 方法可以将 SelectionRange 折叠到开始或结束位置。