This documentation is archived and is not being maintained.

TextRange.InsertBefore Method

Office 2007
Appends a string to the beginning of the specified text range. Returns a TextRange object that represents the appended text. When used without an argument, this method returns a zero-length string at the end of the specified range.



expression   A variable that represents a TextRange object.


NameRequired/OptionalData TypeDescription
NewTextRequiredStringThe text to be inserted. The default value is an empty string.

Return Value


This example adds the Microsoft Office Publisher build number and a paragraph break to the beginning of the first shape on the first page of the active publication. This example assumes the specified shape is a text frame and not another type of shape.

Visual Basic for Applications
Sub InsertTextBefore()
    With ActiveDocument.Pages(1).Shapes(1)
        .TextFrame.TextRange.InsertBefore _
            NewText:="Microsoft Publisher Build : " & Build & vbCrLf
    End With
End Sub