Share via


SearchInfo Object

SharePoint Designer Developer Reference

Provides access to programmatic search and replace functionality to pages in Microsoft Office SharePoint Designer.

Remarks

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

Visual Basic for Applications
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.

Visual Basic for Applications
objSearch.Find = "p"
objSearch.Action = SearchActionFindTag

Use the Find method of the Document object to perform the search. The following example performs the search defined in the previous example and starts at the insertion point.

Visual Basic for Applications
Dim blnFound As Boolean
Dim objRange As TextRange
Set objRange = Application.ActiveDocument.selection.createRange
blnFound = Application.ActiveDocument.Find(objSearch, Nothing, objRange)

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

Visual Basic for Applications
Dim objSearch As SearchInfo
Dim blnFound As Boolean
Dim objRange As TextRange
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

See Also