Bewerken

Delen via


FindReplace.ReplaceWithText property (Publisher)

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

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.