Home | Tips | Library | Other Authors | Other WP Sites | Writer's Links | Contact | Site Map |
Toolbox for WordPerfect |
||
Macros,
tips, and templates for Corel® WordPerfect® for Windows® |
||
Download REPLACEM.ZIP (Version 1.2; 1/8/05; 17,297 bytes) Compatible with WordPerfect versions 6,78,9,10,11,12,X3 WordPerfect 11 users: See important information about using macros in the first release of WP11 (11.0.0.233) at the top of this page. Downloading, Documentation, Modifications, and Support Related macro: See footnote. |
This is a macro that you can use to find and replace many words or phrases in the current document in one easy operation. You can make extensive changes to existing documents with a mouse click. Why use it? WordPerfect's QuickCorrect only works to replace words as you type; it can't find and replace existing (i.e., already typed) words. For that you usually use Edit, Find and Replace. But Find and Replace only works with a word or a phrase at a time, whereas this macro can work with dozens of words or phrases at a time. It is useful whenever you need to make more than a few Find-and-Replace passes in a documentespecially if you need to repeat the same operation using the same words on additional documents. Simply store your replacements in a 2-column table in a separate WordPerfect file that you create first. This "lookup table" makes it easy to update the word list as well as keep separate lists for different projects. Be sure to read the brief instructions embedded at the top of the macro itself (just use WordPerfect to edit the macro). Note that the words or phrases in column 1 of the lookup table are apparently limited by WordPerfect's own Find function to about 79 characters, but if they are found, they will be replaced by the word or phrase in column 2 of the same table row. (If there is a blank cell in column 2, the word or phrase in column 1 will be deleted in the main document -- the equivalent of manually using WordPerfect's Replace function with <nothing> entered in the Replace field.) TIPS
|
If you only need to apply formatting to several words or phrases in a document -- wherever they are found -- you can use a macro like the one below (after a macro published by Greg Turner and Kenneth Hobson on WordPerfect Universe here). Assume you wish to apply italics to these words that might be in a document:
The simplest thing to do is first create a separate, plain text (ANSI or ASCII) file with each item on a separate line. (This "source word" file can be created with a text editor, or it can be created in WordPerfect and saved as ANSI Text. For a simpler version of this macro that might appeal to those who write macros "on the fly," see Footnote 2 below.) Then modify the macro code below (the items in red) to point to the text file and to tell the macro which attribute to apply. Then play the macro. [To copy its code into WordPerfect, see here for instructions.] Please note:
// Macro begins here - // Set the drive, path
and filename of the external "source" text file
- // Set the type of attribute
to apply - FileExists(x;vFN) pResetFindReplace () // This snippet was posted by
Kenneth Hobson on WordPerfect Universe at Array[]=FileToArray(vFN) // This snippet is modeled after code posted by Greg Turner - ForEach(vVar;Array[]) // Exit macro here - // PROCEDURES AND FUNCTIONS HERE: // Function by Kenneth Hobson
- Procedure pResetFindReplace () // Macro ends
Here is a simple version of the above macro (created by Greg Turner) for those who want to write a code snippet "on the fly" to do a simple job: Add an attribute (e.g., italics) to several different words wherever they are found in a document. With each word/phrase on its own line in the Array[] command, the list can be selected and sorted alphabetically, if desired, to make it easier to maintain and update. [For a macro that can do the same job as REPLACEM above -- but with a find/replace list created inside the macro code -- see Footnote 3.] Be sure to REPLACE the sample 6 words ("Agreement," etc.) inside the Array[] with those words you need to process. Be sure the last item does NOT end with a semicolon. NOTE that the words (or phrases) should not be longer than 79 characters each, including spaces, but excluding the pair of double quote marks (which are required). Also note that you can search for words using the Case Sensitive option by enabling that command below by removing the pair of slash (//) marks. Once the words are processed, you can instantly delete the attributes, add additional attributes, or change attributes with Ron Hirsch's REPLACE CODES macro here. // Macro begins Array[]={ Return // (exit here) // Macro ends Here is a macro posted by Roy "lemoto" Lewis on WordPerfect Universe (4/16/08, and modified slightly here) that finds each word/phrase in a list and replaces it with another word/phrase. For example: ...replace "first"
with "second" Notes
// Macro begins pResetFindReplace () Prompt ("Replacing";"Please wait"; NoButtons!| InformationIcon!) /* IMPORTANT: Array[]={ SearchCaseSensitive (Yes!) // Return Find and Replace parameters
to defaults: // Return to original cursor
location: EndPrompt Return // (exit here) Procedure pResetFindReplace () // Macro ends |
|