|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
In a macro to clean up language, what functions do "ClearFormatting" and "Replacement" serve?
I have a macro I've been using that cleans up documents. For instance, for the sentence "This is like X i.e. which is like Y", my macro adds commas before and after "i.e.": "This is like X, i.e., which is like Y".
This macro has the following code at the beginning: Code:
Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting (The macro works fine, but I added something before these lines, and went to comment these lines...only to realize I'm not sure what they do.) |
#2
|
||||
|
||||
Those two lines remove any possible remnants of formatting from the Find and Replace dialog before you set the new search parameters. This is necessary sometimes if a previous find and replace was performed and you had set a particular format to go along with either the find string or the replace with. For example, if you did a search for the word Title and only wanted to find the instances that were bold and then you wanted to assign it as a Heading 1 style then the bold would be a find format and the style setting would be a find.replacement format.
Those settings are sticky - which means the settings are remembered if you close the dialog and then later re-open it without restarting Word. Those lines of code remove those format settings to the find/replace doesn't retain anything you forgot about.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
Thank you very much. That is a great explanation and I have commented my file accordingly.
I will keep this in mind for my other programs too. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Excel 2003: VBA "Function" causes "#VALUE!" errors after running "insert/delete row" custom macro | Matt C | Excel Programming | 2 | 01-08-2022 06:03 AM |
Creating a "super macro" with all kind of functions | Xanthopteryx | PowerPoint | 1 | 06-16-2016 01:38 AM |
How to send "clean" copy after tracking/ redlining changes in review mode | lindapaul | Word | 2 | 06-09-2016 02:34 PM |
remove repeated words with " macro " or " wild cards " in texts with parentheses and commas | jocke321 | Word VBA | 2 | 12-10-2014 11:27 AM |
How to choose a "List" for certain "Heading" from "Modify" tool? | Jamal NUMAN | Word | 2 | 07-03-2011 03:11 AM |