Finding and Replacing Text
The ability to find text and/or formatting in a document, and optionally replace it, is an important part of many custom Office solutions. When using the Word application directly, you use the Find and the Find and Replace dialog boxes to perform these tasks. In a VBA program, the Find object provides the same functionality as these dialog boxes.
Both the Selection object and the Range object have a Find property that provides a reference to a Find object that you can use with that selection or range. The general procedure is as follows:
Listing 0 Define a selection or, more often, a range that includes the part of the document you want to search.
Listing 1 Set the Find object's properties to specify the search details. ...
Get Office® XP Development with VBA now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.