MessageBox.Show("The text could not be located.") Ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ()Ī() Įxecute the search and display a message box with the results. Dim findText As String = "find me"Ĭlear formatting from previous searches. To find text using a Selection objectĪssign a search string to a variable. Clear formatting from previous searches by using the ClearFormatting method prior to the search. It is important to note that the Find criteria are cumulative, which means that criteria are added to previous search criteria. When the item is found that matches the search criteria, it is automatically selected. If the Selection is an insertion point, then the document is searched. When you use a Selection object to find text, any search criteria you specify are applied only against currently selected text. For more information, see Features available by Office application and project type. Use a Find object to loop through a Microsoft Office Word document and search for specific text, formatting, or style, and use the Replacement property to replace any of the items found.Īpplies to: The information in this topic applies to document-level projects and VSTO Add-in projects for Word. The replace command is an extension of the find command. The Find object is a member of both the Selection and the Range objects, and you can use either one to search for text in Microsoft Office Word documents.
Applies to: Visual Studio Visual Studio for Mac