Selection.InsertBefore method (Word)
Inserts the specified text before the specified selection. .
expression Required. A variable that represents a Selection object.
|Text||Required||String||The text to be inserted.|
After using this method to insert text, the selection is expanded to include the new text. If the selection is a bookmark, the bookmark is also expanded to include the next text.
You can insert characters such as quotation marks, tab characters, and nonbreaking hyphens by using the Visual Basic Chr function with the InsertBefore method. You can also use the following Visual Basic constants: vbCr, vbLf, vbCrLf and vbTab.
This example inserts the text "Hamlet" (enclosed in quotation marks) before the selection and then collapses the selection.
With Selection .InsertBefore Chr(34) & "Hamlet" & Chr(34) & Chr(32) .Collapse Direction:=wdCollapseEnd End With
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.