Table of contents
TOC
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.

Syntax

expression. ReplaceWithText

_expression_A variable that represents a FindReplace object.

Return Value

String

Remarks

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.

Example

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

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