SearchInfo Object

Microsoft FrontPage Visual Basic

SearchInfo Object

SearchInfo

Provides access to programmatic search and replace functionality to pages in Microsoft FrontPage.

Using the SearchInfo object

Use the CreateSearchInfo method to create a SearchInfo object. The following example creates a new SearchInfo object.

    Dim objSearch As SearchInfo

Set objSearch = Application.CreateSearchInfo
  

Use the Find property to specify a character or string of characters for which to perform the search. Use the Action property to specify the type of search to perform. The following example sets the Find and Action properties for the SearchInfo object created in the previous example.

    objSearch.Find = "p"
objSearch.Action = fpSearchFindTag
  

Use the Find method of the FPHTMLDocument object to perform the search. The following example performs the search defined above starting at the insertion point.

    Dim blnFound As Boolean
Dim objRange As IHTMLTxtRange

Set objRange = Application.ActiveDocument.selection.createRange
blnFound = Application.ActiveDocument.Find(objSearch, Nothing, objRange)
  

The following example combines the above code samples. This example searches for the next occurrence of the P element. If the P element is found, it selects the P element and associated text.

    Dim objSearch As SearchInfo
Dim blnFound As Boolean
Dim objRange As IHTMLTxtRange

Set objSearch = Application.CreateSearchInfo
objSearch.Find = "p"
objSearch.Action = fpSearchFindTag

Set objRange = Application.ActiveDocument.selection.createRange
blnFound = Application.ActiveDocument.Find(objSearch, Nothing, objRange)
If blnFound = True Then objRange.Select