TextRange.InsertBefore method (Publisher)

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.

Syntax

expression.InsertBefore (NewText)

expression A variable that represents a TextRange object.

Parameters

Name Required/Optional Data type Description
NewText Required String The text to be inserted. The default value is an empty string.

Return value

TextRange

Example

This example adds the Microsoft 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 that the specified shape is a text frame and not another type of shape.

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

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.