Home | Tips | Library | Other Authors | Other WP Sites | Writer's Links | Contact | Site Map | Donate |
![]() Toolbox for WordPerfect |
||
Macros, tips, and
templates for Corel® WordPerfect® for Windows® |
Page updated May 8, 2019 |
|
REPLSTYL -
Replace one style with another, or remove a style from the document |
||
|
Purpose / Overview This macro replaces a chosen Paragraph style
or a Character style wherever it is found in the document with another
Paragraph or Character style. It can also remove all instances of a
chosen style rather than replace them, optionally pausing for user
confirmation. [For more on WordPerfect styles, see here.] Background Depending on a setting in the program's Styles Editor, WordPerfect allows you to globally change an existing style throughout a document by simply editing the style, thus:Click on Format, Styles, and choose a style; then click Edit to bring up the Styles Editor to make your changes Or, you can simply double-click the style's code in Reveal Codes to bring up the Styles Editor. While in the Styles Editor you can check (tick) the box, "Automatically update style when changed in document" so that later changes can be made globally throughout the document either in the Styles Editor or by merely applying a formatting change (such as a special color, etc.) to any instance of text to which that style was applied. However: It may be more desirable or more convenient -- and probably faster -- to replace one style with another style (usually of the same type, Paragraph or Character) everywhere in the document. This is the main purpose of this macro. The macro also lets you remove the style (but not the text to which the style was applied) by deleting the style's codes. You can choose to do either of these things in one operation, or have the macro pause for confirmation at each style's location. (In the latter case the macro will have opened the Reveal Codes window so that you can see the style codes at that location.) Important notes • Styles in the document:The style you
choose to replace (or remove), as well as the style to use as a
replacement, must already exist in the document or in the template that
spawned it. If not, the macro will pop up a message and then return to
the menu, where you can either make a different choice or cancel the
macro and apply the missing style to some text.
• Replacements: This macro does
NOT work to replace Document (i.e., "open") styles, which do not use
paired codes (open styles have only a beginning code, which means the
style will remain in effect until it is changed further down in the
document).
The macro only works to replace Paragraph and Character styles, which have a beginning and ending code surrounding their text. You can determine if the styles to be used by this macro are either Paragraph or Character styles: The type of style
in effect in a document -- Character, Paragraph, or Document -- should
be visible on the code itself in Reveal Codes. Just pass your cursor
over the code.
Or, you can double-click each style's code (if available) in the document's Reveal Codes window and look under 'Type' in the Styles Editor that pops up. [Alternatively, use Format, Styles to display the Styles Editor, where the styles should be listed; choose the style and click Edit to determine the style's Type.] Note that if you replace a Character style with a Paragraph style, the latter will apply the style to the entire current paragraph (hence its name). [For more on these three types of text styles see here. • Removals: This macro will
work to remove Document (open) styles, as well as Paragraph and
Character styles. This is because it always searches for the first code
with the specified name and deletes it, regardless of the desired
operation. Paragraph and Character styles are paired codes; hence,
deleting just the first (or last) code in the pair will delete the
style.
Tips: If you need to remove a style containing format codes but you want to retain those format codes in the document, simply click on Format, Styles, <choose the style>, Options, Delete, "Leave formatting codes in document," OK. Later, you can change these (or any) text attribute codes in the document to different codes (or just remove them) with the Replace Codes macro in the Library. • Specifying styles: On the main menu,
be sure to enter any custom (i.e., user-created) style's name EXACTLY
(including upper/lower case) as it appears in the Style drop list on
the property bar for this document. Check to see if the style you need
is already listed there (i.e., Heading styles); if so, simply click on
the name.
Style names can be up to 12 characters long. • Pausing for confirmation: If you choose
"Prompt for confirmation," the macro will obviously run more slowly as
it pops up a Yes/No/Quit dialog on your screen. To help you see which
style is currently being processed when the macro pauses for
confirmation, look in the Reveal Codes window, which is opened (if it
was not already open) while the macro runs.
• Outline styles: If you are trying to replace a paragraph outline (e.g., Para Style: Level 1) with another paragraph outline
(e.g., Para Style: Legal 1), try using the more direct approach of
clicking Insert, Outline/Bullets... (or double-click the [Outline] code
above the outline items) and choosing the new outline from the Bullets
& Numbering dialog. You probably don't need to use this macro for
such a purpose.
In fact, since a
WordPerfect outline is really a combination of a paragraph number and a
"level" style (click on Edit in the Bullets & Numbering dialog and
you'll see the link between paragraph numbers and specific styles at
each outline level), using this macro to replace one outline with
another will perform only half the task by replacing just the style
portion of the outlines. You would still need to reset the numbering
for each paragraph level, too.
[To do this, double-click the [Outline] code at the at the top of the document or at the beginning of the outlined material and when the Bullets & Numbering dialog opens, select the new outline's name and click OK. This will reset the numbers for the outline that is present in the document.] • Back ups: It is always a good idea to play any macro on a copy of your document.
Alternative (manual method) Arcane tip: It is possible to swap two styles using the three-step "ABC" method: To swap style "A" with style "B," first create a temporary style "C" -- perhaps a simple style (Character or Paragraph, depending on style A's type) created with little or no formatting, using a QuickStyle. The temporary style is used to move style A out of the way temporarily. Then use this macro to replace A with C (i.e., A becomes C), then replace B with A (i.e., B becomes A), then replace C with B (i.e., C -- which was A -- becomes B).
It might be helpful to use a QuickStyle (style C) that is readily identifiable (such as a redlined or highlighted style) to help identify where you are in the three-step process. For example, place the cursor on a redlined word in the document, and select "QuickStyle" from the Select Style drop list on the text property bar. Give the QuickStyle a name, choose Paragraph or Character, and click OK. Use this temporary style as style C in the ABC method. |
|