Selection.InsertBefore method (Word)

Inserts the specified text before the specified selection. .

Syntax

expression. InsertBefore( _Text_ )

expression Required. A variable that represents a Selection object.

Parameters

Name Required/Optional Data type Description
Text Required String The text to be inserted.

Remarks

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.

Example

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

See also

Selection Object

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.