Table of contents
Collapse the table of content
Expand the table of content

FindReplace.ReplaceWithText Property (Publisher)

office 365 dev account|Last Updated: 8/24/2017
3 Contributors

Sets or retrieves a String representing the replacement text in the specified range or selection. Read/write.


expression. ReplaceWithText

_expression_A variable that represents a FindReplace object.

Return Value



The default setting of the ReplaceWithText property is an empty String.

If the ReplaceScope property is set to either pbReplaceScopeOne or pbReplaceScopeAll and the ReplaceWithText property is not set, the text found will be replaced with the default empty string, thus removing the text.


The following example replaces all occurrences of the word "hello" with "goodbye" in the active document.

With ActiveDocument.Find 
 .FindText = "hello" 
 .ReplaceWithText = "goodbye" 
 .MatchWholeWord = True 
 .ReplaceScope = pbReplaceScopeAll 
End With
© 2018 Microsoft