FindText Property

Microsoft Publisher Visual Basic

FindText Property

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

expression.FindText

expression    Required. An expression that returns a FindReplace object.

Remarks

The FindText property returns the plain, unformatted text of the selection. When you set this property, the search text is specified. You can search for special characters by specifying appropriate character codes. For example, "^p" corresponds to a paragraph mark and "^t" corresponds to a tab character.

The default value for the FindText property is an empty string. Because only text searching is supported, FindText must be explicitly set to avoid a runtime error.

Examples

This example replaces all occurrences of the word "This" in the selection with "That" in each open publication.

      Dim objDocument As Document

For Each objDocument In Documents
    With objDocument.Find
        .Clear
        .MatchCase = True
        .FindText = "This"
        .ReplaceWithText = "That"
        .ReplaceScope = pbReplaceScopeAll
        .Forward = True
        .Execute
    End With
Next objDocument

    

This example replaces all tab characters with paragraph marks.

    Dim objDocument As Document

For Each objDocument In Documents
    With objDocument.Find
        .Clear
        .MatchCase = True
        .FindText = "^t"
        .ReplaceWithText = "^p"
        .ReplaceScope = pbReplaceScopeAll
        .Execute
    End With
Next objDocument