Word Reference

Inserting Text in a Document

Direct Answer

Inserting Text in a Document is part of the Word VBA object model. This reference page documents its syntax, parameters, and typical usage.

Reference

Use the InsertBefore method or the InsertAfter method of the Selection object or the Range object to insert text before or after a selection or range of text. The following example inserts text at the end of the active document.

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

The following example inserts text before the selection.

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

After using the InsertBefore method or the InsertAfter method, the Range or Selection expands to include the new text. Use the Collapse method to collapse a Selection or Range to the beginning or ending point.

!include[Support and feedback]

Reference: Word object-model documentation • updated 06/08/2019. Rebuilt for readability; see the original for complete parameter matrices.