TypeText Method

Microsoft Word Visual Basic

Inserts the specified text. If the ReplaceSelection property is True, the selection is replaced by the specified text. If ReplaceSelection is False, the specified text is inserted before the selection.

expression.TypeText(Text)

expression    Required. An expression that returns a Selection object.

Text    Required String. The text to be inserted.

Example

If Typing replaces selection is selected on the Edit tab in the Options dialog box, this example collapses the selection before inserting "Hello." This technique prevents existing document text from being replaced.

If Options.ReplaceSelection = True Then
    Selection.Collapse Direction:=wdCollapseStart
    Selection.TypeText Text:="Hello"
End If
		

This example inserts "Title" followed by a new paragraph.

Options.ReplaceSelection = False
With Selection
    .TypeText Text:="Title"
    .TypeParagraph
End With