ReplaceWithText Property

Microsoft Publisher Visual Basic

ReplaceWithText Property

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

expression.ReplaceWithText

expression    Required. An expression that returns a FindReplace object.

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