
ParagraphFormat.LineSpacingRule = wdLineSpacing.wdLineSpaceDouble The following example finds the next double-spaced paragraph after the selection. Set objRange = ActiveDocument.Sentences(2) When the Execute method of the Find object is executed successfully a new Range object is returned If you want to find and replace special characters you may need to prefix them with a back slash objFind.Text = "\" If you are looking for certain text always use Range.Find Looping through paragraphs in a document is very slow You can use the Find object's Found property to iterate through several found items instead of checking the return value of Execute everytime. True to search forward (toward the end of the document). Corresponds to the Find all word forms check box in the Find and Replace dialog box.įorward - Optional Variant.

True to have the find operation locate all forms of the find text (for example, "sit" locates "sitting" and "sat"). Corresponds to the Sounds like check box in the Find and Replace dialog box. True to have the find operation locate words that sound similar to the find text. Corresponds to the Use wildcards check box in the Find and Replace dialog box. True to have the find text be a special search operator. Corresponds to the Find whole words only check box in the Find and Replace dialog box. True to have the find operation locate only entire words, not text that's part of a larger word. Corresponds to the Match case check box in the Find and Replace dialog box (Edit menu). True to specify that the find text be case sensitive. For a list of special characters you can use, see Find and replace text or other items.

For example, "^p" corresponds to a paragraph mark and "^t" corresponds to a tab character. You can search for special characters by specifying appropriate character codes. Use an empty string ("") to search for formatting only. Whether to find formatting in addition to or instead of the Find text ?įind.Execute expression.Execute(FindText:="text to find", _įindText - Optional Variant. The Find property returns a Find object that you can use to Search a Range.
