Macro of the Month – March 2024 – CopyToListAlphabetic
Copies words to the word list section of your style sheet in alphabetical order
last updated: 12/12/2024
This month’s macro upgrades the CopyToList macro. It does even more of the work of populating your style sheet. Also, for those who want an introduction to macros, Paul and I are doing a webinar for the European Association of Science Editors in April. And if you haven’t filled out the survey to tell us what type of macro training you want, there are still a few days left.
CopyToListAlphabetic
The October 2023 newsletter about CopyToList was one of the most popular we’ve ever had. It’s not surprising, considering how essential style sheets are. And then Erin Cusick had an idea to make it even more useful. CopyToList adds words to your style sheet, but they are added wherever the cursor happens to be located at the time. Erin wanted a macro that would add words to the word list section of the style sheet and put them in alphabetical order. Paul, as always, happily came up with a new macro: CopyToListAlphabetic.
How It Works
When you want to add a word to your style sheet, run CopyToListAlphabetic. It copies the word (plus formatting, if it has any) and pastes it into your style sheet in the word list section in alphabetical order. This all happens in the background so you can maintain your attention on the flow of editing.
If the selected term is already in the style sheet, the macro will beep; it doesn’t add the term a second time.
Basic Setup and Usage
Before you can use CopyToListAlphabetic for a new project, you need to set up your style sheet file name (so the macro knows which document is the style sheet) and the header for the word list section (so the macro knows where to place the terms). Follow these steps:
Include the word “sheet” in the file name for your style sheet (e.g., style_sheet_project.docx) so the macro knows which open document is the style sheet.
Format the word list section of your style sheet as “Word list”—using that exact capitalization.
To use the macro:
Keep your style sheet open (it can be on a second screen or in the background).
In your working document:
To add a single word: Place your cursor anywhere in the word.
To add a hyphenated term: place the cursor inside the first word.
To add a multi-word term: Select the entire term, or roughly select it by clicking inside the first word, holding down the Shift key, and clicking inside the last word.
Run CopyToListAlphabetic
Note, if the word you’re adding contains Track Changes markings, it will paste it into your style sheet with the tracking accepted.
Download the code: www.wordmacrotools.com/macros/C/CopyToListAlphabetic
Customizing the macro
You can use a different file name for your style sheet and word list header by adjusting the code. You can also have the macro ignore the formatting.
1. Change the required file name
If the file name for your style sheet doesn’t contain the word “sheet,” such as style_guide_novel.docx, replace “sheet” in the below line of code with “guide” (or “style,” if you prefer).
keyWord = "sheet"
2. Change the required heading name
To use a different header for your word list, such as Character Names, replace “Word list” in the below line of code with “Character Names,” making sure the capitalization matches.
followHeading = "Word list"
3. Don’t copy the formatting of the word
If you want the macro to ignore the formatting of the words (such as italics and bold), adjust the code by deleting the apostrophe from the beginning of the includeFormatting = True line and adding one in front of the includeFormatting = False line.
' includeFormatting = True
includeFormatting = False
4. Silence the beep
When a word is already in your style sheet, the macro will beep when you run it to tell you. You can silence it by changing beepIfAlreadyListed = True to beepIfAlreadyListed = False as shown below.
beepIfAlreadyListed = False
Tips for complex style sheets
If you want to copy different terms to different sections of your style sheet, you can use multiple copies of CopyToListAlphabetic to do that. Follow these steps:
Install multiple copies of CopyToListAlphabetic, each with a unique name, such as CopyToListAlphabetic, CopyToListAlphabeticPLACE, CopyToListAlphabeticPEOPLE.
In the code for each macro, follow the instructions above to specify the header where you want the terms to be added, such as Word List, Place Names, People & Organization Names.
To make running each macro seamless, use function keys for the shortcuts, such as F4, F5, F7. (Depending on your keyboard shortcut, you may need to use the Function key as well: Fn+F4, Fn+F5, Fn+F7.)
Related macros
If you prefer the functionality of CopyToList, read about it in the October 2023 newsletter. For complex style sheets, CopyToListAlphaMenu helps you manage multiple word lists by giving you a menu to indicate which list the selected term should be added to; it requires the use of only one shortcut compared to the above technique of duplicating CopyToListAlphabetic for each word list. Read about how to use and set it up in the October 2024 newsletter.
Upcoming Training
I will be presenting Macro Magic, a webinar for EASE (European Association of Science Editors) on April 16 at 2 p.m. UK time. This one-hour session will give an introduction to what macros are, why they are invaluable to editors, and resources for learning how to use them. There will be a Q&A at the end featuring Paul Beverley. It’s free to members; the nonmember fee is 25 euros.
Please share this with your colleagues who have been wanting to learn about macros.
Help Us Create More Training: A survey
Last days to complete the survey. Help Paul Beverley and me create additional free training materials for his macros. What macro skills do you want to improve? Please tell us by completing this short survey, about 4–10 minutes. Whether you are an experienced macro user or you don’t currently use them, we want to hear from you. The survey closes April 1.
Questions? Have you recently discovered a macro you want to share with other editors? Comment on this post.
Happy macroing,
Jennifer