Share via


ReplAll: Uses Automation to Implement Replace Across Open Text Files

ReplAll resembles the Find and Replace dialog box but will find and replace text in all open text files.

To build the sample

  1. Click the link at the beginning of this topic to download the sample files.

  2. In Visual C++, open the project file ReplAll.dsp.

  3. Choose an appropriate configuration (Win32 Release is best if you plan to use this add-in).

  4. Click Rebuild All from the Build menu.

To run the add-in

  1. From the Tools menu, click Customize.

  2. Click the Add-ins and Macro Files tab.

  3. Select the ReplAll.dll file or browse for it. See Tips for Using Add-ins.

    Visual C++ will load the add-in. When you close the Customize dialog box, ReplAll’s toolbar will appear.

  4. Run the ReplAll add-in by clicking the toolbar button. Clicking this button opens a dialog box that resembles the Find and Replace dialog box in Visual C++:

    • It has check boxes for Match whole word only, Match case, and Regular Expression as well as buttons for Replace All and Cancel.

    • It has two edit boxes: Find what and Replace with.

ReplAll deals with the various emulation modes, such as the Brief and Epsilon editors.

This sample demonstrates the following keywords:

IApplication, CComPtr, CComQIPtr; CComBSTR; CComVariant; IDocuments::get__NewEnum; IEnumVARIANT::Next; CComVariant; IDocuments::get_Count; Item; ITextDocument::ReplaceText; ITextEditor::get_Emulation ; IApplication::get_ActiveDocument ; addin; customize; ItextDocument; ITextSelection