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

Concepts

Selection Object Members

Selection Object