Class Replacement (Word VBA)

The class Replacement represents the replace criteria for a find-and-replace operation. The properties and methods of the Replacement object correspond to the options in the Find and Replace dialog box.

To use a Replacement class variable it first needs to be instantiated, for example

Dim rpl as Replacement
Set rpl = Selection.Find.Replacement

Replacement class variables can be set using the Find.Replacement procedure.


Removes text and paragraph formatting from the text specified in a replace operation.

Sub ClrFmtgReplace() 
 Dim rngTemp As Range 
 Set rngTemp = ActiveDocument.Content 
 With rngTemp.Find 
 .MatchWholeWord = True 
 .Execute FindText:="Inc.", ReplaceWith:="incorporated", _ 
 End With 
End Sub


Returns or sets a Font object that represents the character formatting of the specified object.

To set this property, specify an expression that returns a Font object.

Selection.Find.Replacement.Font =


Returns a Frame object that represents the frame formatting for the specified style or find-and-replace operation.

Dim frmFrame As Frame
Set frmFrame = Selection.Find.Replacement.Frame


True if highlight formatting is applied to the replacement text.

Can return or be set to True, False, or wdUndefined.

Dim rngTemp As Range 
Set rngTemp = ActiveDocument.Range(Start:=0, End:=0) 
With rngTemp.Find 
 .Highlight = True 
 With .Replacement 
 .Highlight = False 
 End With 
 .Execute Replace:=wdReplaceAll, Forward:=True, FindText:="", _ 
 ReplaceWith:="", Format:=True 
End With


Returns or sets a WdLanguageID constant that represents the language for the specified range. Here you can find possible values for WdLanguageID.

Some of the WdLanguageID constants may not be available to you, depending on the language support (U.S. English, for example) that you've selected or installed.

Selection.Find.Replacement.LanguageID = wdAfrikaans


Returns or sets an East Asian language for the specified replacement. Here you can find possible values for WdLanguageID.

This is the recommended way to return or set the language of East Asian text in a document created in an East Asian version of Microsoft Word.

Selection.LanguageIDFarEast = wdKorean


True if Microsoft Word replaces text that the spelling and grammar checker ignores.

Selection.Find.Replacement.NoProofing =


Returns or sets a ParagraphFormat object that represents the paragraph settings for the specified replacement operation.

With ActiveDocument.Content.Find 
 .Execute FindText:="", ReplaceWith:="", _ 
End With


Returns or sets the style for the specified style. To set this property, specify the local name of the style, an integer, a WdBuiltinStyle constant, or an style that represents the style. Read/write Variant.

When you return the style for a range that includes more than one style, only the first character or paragraph style is returned.

Selection.Find.Replacement.Style =


Returns or sets the text to replace.

Set myRange = ActiveDocument.Content 
With myRange.Find 
 .Text = "Hello" 
 .Replacement.Text = "Goodbye" 
 .Execute Replace:=wdReplaceAll 
End With