Edit

Share via


Replacement.ClearFormatting method (Word)

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

Syntax

expression.ClearFormatting

expression A variable that represents a 'Replacement' object.

Example

This example clears formatting from the find or replace criteria before replacing the word "Inc." with "incorporated" throughout the active document.

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

See also

Replacement 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.