Selection.TypeText method (Word)

Inserts the specified text.

Important

This method has changed. Using VBA Selection commands like Selection.BoldRun on user selection with Comments no longer applies bold formatting on user-selected text or Selection.TypeText command or on user selection with Comments no longer inserts text.

Syntax

expression. TypeText( _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

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.

Example

If Word is set so that typing replaces selected text, 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

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.