Inserting Text in a Document
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.
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for