Jack Lyon

Creating Toolbars

A few weeks ago, we talked about how to create toolbar buttons to activate your macros, but the fact is, you can create your own toolbars as well. Then you're not stuck with the toolbars that come with Microsoft Word. Here's how:

In Word 97 or later:

1. Click the "Tools" menu.

2. Click "Customize."

3. Click the "Toolbars" tab.

4. Click the "New" button.

5. In the box labeled "Toolbar name," type a name for your toolbar, such as "My Macros."

6. In the box labeled "Make toolbar available to," select the template or document where you want your toolbar to live. This will probably be your Normal template (Normal.dot), which will make your toolbar available to any document. You could also select another template or document, however.

7. Click the "OK" button.

8. Click the "Close" button.

In Word 6 or 95:

1. Click the "View" menu.

2. Click "Toolbars."

3. Click the "New" button.

4. In the box labeled "Toolbar name," type a name for your toolbar, such as "My Macros."

5. In the box labeled "Make toolbar available to," select the template or document where you want your toolbar to live. This will probably be your Normal template (Normal.dot), which will make your toolbar available to any document. You could also select another template, however.

6. Click the "OK" button.

7. Click the "Close" button.

Once you've created your toolbar, you can add macros to it as described in the June 27, 2001, issue of Editorium Update, which you can read here:

http://www.topica.com/lists/editorium/read/message.html?mid=1707286867

Customizing Microsoft Word

When you first install Microsoft Word, it's set up for the "generic" user--someone who employs only the most basic features of this powerful program. For example, it displays the Standard and Formatting toolbars but not the AutoText or Reviewing toolbars. But if you're editing or typesetting in Word, you're not a generic user--far from it. You could probably *use* the AutoText and Reviewing toolbars. And maybe that Standard toolbar doesn't do much of anything for you. Don't be afraid to set up Word so that you can work as efficiently as possible. Here are some tips on how to do that:

1. During a typical workday, notice which features of Word you use the most. You might even make a list and put a check mark next to a feature each time you use it. Then count up the check marks for each feature at the end of the day.

2. If you're using menus or toolbars to access these features, learn and then use their keyboard shortcuts (see "Keyboard Shortcuts" in Word's Help file). Over the course of a year, this will save you an enormous amount of time because you won't be reaching for the mouse every thirty seconds. If the features don't have keyboard shortcuts, make your own, as explained in the Readers Write column of the June 13, 2001, Editorium Update, which you can read here:

http://www.topica.com/lists/editorium/read/message.html?mid=1707100224

3. Explore Word's toolbars by clicking the "View" menu and then "Toolbars." Some of these (Control Toolbox, Visual Basic) may be completely meaningless to you. Others, however (Clipboard, Tables and Borders), you may find very useful.

4. Rearrange menu items and toolbar buttons in ways that make sense to you. Don't settle for Word's out-of-the-box arrangement. Word was *made* to be customized! Go ahead--pull off those buttons you never use. Move buttons from one toolbar to another. If you know that never in your life are you going to use the Letter Wizard, why keep it on your "Tools" menu? Get rid of it! Make your Word window as sleek and efficient as the cockpit of a jet. You can read the basic instructions for customizing toolbars and menus in the past two issues of Editorium Update, here:

http://www.topica.com/lists/editorium/read/message.html?mid=1707286867

http://www.topica.com/lists/editorium/read/message.html?mid=1707444986

5. Go spelunking. Use Word's menus to explore features you may not have seen before. Check out Document Map, Change Case, Word Count, Track Changes, and (if you're a keyboard junkie) Full Screen View. Some of these features will make you smile. When they do, remember where they are (make another list) or put them on menus and toolbars where you can find them again.

6. If you've recorded certain macros that you use a lot, make them easily accessible with keyboard shortcuts, toolbar buttons, and menu items.

If the idea of changing toolbars and menus scares you, just be sure to back up your Normal template (Normal.dot, which resides in your Templates folder). Then, if you need to, you can go back to your original configuration by replacing your new Normal template (where your customizations are stored) with your old, generic one. You can also keep your customizations (and macros) in your own add-in template, as explained here:

http://www.topica.com/lists/editorium/read/message.html?mid=1707194086

Remember, too, that just because you remove a feature from a toolbar or menu doesn't mean it's really gone. You can always put it back if you need to. Over the next few weeks, I'll explain how to create your own toolbars and menus (not just modify existing ones) and add or remove features. I'll also show you the secret repository for *all* of Word's features--many of which are not on *any* menu, toolbar, or keyboard shortcut. If you're interested in customizing Word, you won't want to miss that.

Macros on Menus

In our last newsletter, we talked about putting macros on toolbar buttons, but you may prefer putting them on menus instead. Here's how:

In Word 6 or 95:

1. Click the "Tools" menu.

2. Click "Customize."

3. Click the "Menus" tab.

4. In the "Categories" list, on the left, find and click "Macros."

5. In the "Macros" list, on the right, find and click the macro you want to use.

6. In the "Change What Menu" box, find and click the menu you want to use ("Edit," for example, or "Insert").

7. In the "Position on Menu" box, find and click the menu item below which you want your new menu item to appear. (You can also select "Auto" [which lets Word assign the position], "At Top," and "At Bottom.")

8. In the "Name on Menu" box, type the name of your macro as you want it to appear on the menu. (This won't change the actual name of your macro.)

9. Click the "Add" or "Add Below" button.

10. Click the "Close" button.

In Word 97 or later:

1. Click the "Tools" menu.

2. Click "Customize."

3. Click the "Commands" tab.

4. In the "Categories" list, on the left, find and click "Macros."

5. In the "Commands" list, on the right, find and click the macro you want to use and hold down the mouse button.

6. Drag the gray rectangle to the Word menu you want to use ("Edit," for example, or "Insert"). The menu will expand so you can see its entries.

7. Drag the gray rectangle to the position where you want your menu item to appear.

8. Release the mouse button. Your new menu item will appear on the menu, displaying the name of the macro.

9. In Word 97 or later, click the "Modify Selection" button or right-click the menu item you just added. A menu will appear.

10. Use the menu items to change the appearance of your new menu item until you're happy with it (see the explanations below).

11. When you're finished, click the "Close" button.

Your new menu item will appear on the menu you selected, displaying the name of the macro.

Now you can click the menu item to run your macro.

Here's an explanation of the items on the "Modify Selection" menu:

* "Delete" deletes the selected button.

* "Name" lets you change the text displayed on the menu (without affecting the name of the macro).

* "Copy Button Image" copies the icon from a selected button or menu item.

* "Paste Button Image" pastes a copied icon to the left of a selected menu item.

* "Reset Button Image" resets a menu item to its default appearance, which is blank for a new menu item to which you've assigned an icon.

* "Edit Button Image" lets you create your own icons or modify existing ones. Be careful; it's easy to spend hours playing around in here.

* "Change Button Image" lets you select one of Word's built-in icons. I frequently use the smiley face to run a quick-and-dirty macro for a particular project.

* "Default Style" displays the icon and menu name for a menu item that has both an icon and a text name.

* "Text Only (Always)" displays only the menu item's name, hiding the icon if you've assigned one. (The "Always" means this will be true even if you drag the item to a toolbar button.)

* "Text Only (In Menus)" displays only the menu item's name on the menu (but not if you drag it to a toolbar).

* "Image and Text" displays both the icon and the menu item's name.

* "Begin a Group" separates the menu item from previous menu items with a thin, gray line.

* "Assign Hyperlink" lets you use the menu item to link to a Web page, a file, a picture, or other items, but that's a topic for another day.

When you close Word, the program will ask if you want to save the changes you've made to the Normal (or other) template. In other words, do you want to keep the menu item you've added? If you do, click yes (this will also save any other changes you've made to the template).

_________________________________________

READERS WRITE

Subscriber Brian Vicary wrote:

I have read with great interest your articles concerning Word macros--in particular your more advanced series dealing with creating macros and making them available automatically via add-in templates.

As part of our business I visit our clients' sites to install software and to perform updates when necessary. We supply a Word template with predefined macros to make the use of our software easier. On networks we prefer our template to be shared so that we only have one location to update. While this can be accomplished by pointing the Word Startup path to this shared location, it is often not possible if the users already have templates in their Startup folder. Often users already have slightly different Startup templates for their own use or do not need access to a particular template.

You can add templates using the Tools, Templates and Add-Ins option, but you have to manually activate them each time you run Word.

To get round this problem this is what I do:

1. Open Word and then close the blank document that is open.

2. Go to the Tools menu and select the Macro option; from there select the Record New Macro.... option.

3. Give the macro a name appropriate to the macro--for example, AddMyMacro.

4. Click OK to begin recording the macro.

5. Click the Tools menu and select the Templates and Add-Ins option.

6. Click the Add button.

7. Navigate to where the Template document is stored on the network and select it. It should appear in the Add-ins list with a tick.

8. Click the OK button.

9. Stop recording the macro.

10. Go to the Tools menu and select the Macro option; from there select the Macros.... option.

11. Enter the name AutoExec in the Macro Name box and click the Create button. This will open the Visual Basic Editor with the new macro AutoExec.

12. In the sub for AutoExec, enter the name of the new macro you recorded above--for example, AddMyMacro.

13. Close the Visual Basic Editor.

14. Close and restart Word.

Now when Word starts, it automatically runs the macro AutoExec. This in turn runs the macro name you entered, AddMyMacro, which loads and activates the required template.

If you already have an AutoExec macro, just add a new line to it with the name of your macro. Any number of macros can be added this way, and you also have control over who loads what macros, as well as allowing them to maintain a personal Startup path.

You can also add the template in the usual manner without recording a macro, then record a macro of your activating it. The process is exactly the same, and the result is also exactly the same.

The only drawback can be the speed of the network if your macros are complex, but in practice I have not found this to be a major problem. Also, you have to get everyone to close their Word if you need to update any of the Add-on templates. However, this is true whatever method you use for sharing templates.

Hope this may be of interest to any of your readers.

Thanks very much to Brian for this useful tip.

Macros on Buttons

If you've been recording your own macros (as explained in past issues of Editorium Update), you may be interested in putting them on toolbar buttons for easy access. Here's how:

1. Make sure the toolbar you want to use is showing. (You may need to click the "View" menu, click "Toolbars," and then put a checkmark next to the toolbar you want to display.)

2. Click the "Tools" menu.

3. Click "Customize."

4. Click the "Commands" tab. (In Word 6 or Word 95, click the "Toolbars" tab.)

5. In the "Categories" list, on the left, click "Macros."

6. In the "Commands" list ("Macros" list in Word 6 or Word 95), on the right, click the macro you want to use and hold down the mouse button.

7. Drag the gray rectangle (representing a toolbar button) to a suitable position on the toolbar you want to use. (In Word 97 or later, a black "I-beam" will indicate the position of your new button.)

8. Release the mouse button. A new button will appear on the toolbar. (In Word 97 or later, it will display the name of the macro.)

9. In Word 6 or 95, click the icon you want to use, or type in the text for a text button. Then click the "Assign" button.

10. In Word 97 or later, click the "Modify Selection" button or right-click the toolbar button you just added. A menu will appear. (In Word 6 or Word 95, you can display the menu by right-clicking the toolbar button.)

11. Use the menu items to change the appearance of your button until you're happy with it (see the explanations below).

12. When you're finished, click the "Close" button.

Now you can click the button to run your macro from the toolbar.

Here's an explanation of the items on the "Modify Selection" menu (some of these are not available in Word 6 or Word 95):

* "Delete" deletes the selected button.

* "Name" lets you change the text displayed on the button (without affecting the name of the macro).

* "Copy Button Image" copies the icon from a selected button.

* "Paste Button Image" pastes a copied icon to a selected button.

* "Reset Button Image" resets a button to its default appearance, which is blank for a new button to which you've assigned an icon.

* "Edit Button Image" lets you create your own icons or modify existing ones. Be careful; it's easy to spend hours playing around in here.

* "Change Button Image" lets you select one of Word's built-in icons. I frequently use the smiley face to run a quick-and-dirty macro for a particular project.

* "Default Style" displays only the icon for a button that has both an icon and a text name.

* "Text Only (Always)" displays only the button's name, hiding the icon if you've assigned one.

* "Text Only (In Menus)" displays only the button's name if you drag the button to a menu rather than a toolbar (yes, you can do that).

* "Image and Text" displays both the icon and the button's name.

* "Begin a Group" separates the button from previous buttons with a space (in Word 6 or Word 95) or a thin, gray line.

* "Assign Hyperlink" lets you use the button to link to a Web page, a file, a picture, or other items, but that's a topic for another day.

When you close Word, the program will ask if you want to save the changes you've made to the Normal (or other) template. In other words, do you want to keep the button you've added? If you do, click yes (this will also save any other changes you've made to the template).

Creating Add-in Templates

If you've been recording your own macros, as explained in our past several newsletters, you've probably been saving them in your Normal template, where they'll be available to use with any document. The Normal template may not be the best place to save them, however. Since it's used a lot, it can become corrupt. (You should back up your Normal template frequently.) Also, saving macros in your Normal template makes it hard to keep them organized.

What's the alternative? Create your own add-in templates as a place to keep your macros. Doing so has several advantages:

1. It makes organizing your macros easy. You can keep all the macros for a particular project or task in a single add-in template.

2. It makes backing up your macros easy. Just keep copies of your templates in several locations.

3. It makes sharing your macros easy. Just give a copy of a template to a colleague or friend.

For information on how to use add-in templates, please see the past two issues of Editorium Update:

http://www.topica.com/lists/editorium/read/message.html?mid=1707012536

http://www.topica.com/lists/editorium/read/message.html?mid=1707100224

So how do you create an add-in template? Here's the way I like to do it:

1. Create a new document in Microsoft Word.

2. Save the document as a Microsoft Word template, which has a ".dot" extension. Be sure to give it a name that describes the purpose of the macros you're going to store in the template (for example, Cleanup.dot or MyProject.dot).

3. Click the "Tools" menu.

4. Click "Macro" and (in Word 97 or later) "Macros."

5. Click the "Organizer" button.

On the "Macro Project Items" tab, you'll see two windows. The name of the template you just created should be displayed above the left window, which should be empty since the template doesn't contain any macros yet. If the name of your template isn't displayed, click the drop-down list under the window and select it.

The window on the right should show the macros available in Normal.dot (as indicated above the window). If the window isn't displaying Normal.dot, click the drop-down list under the window and select it. Then, do this:

1. Select the macros in Normal.dot that you want to copy to your new template. (To select several at once, hold down the CTRL key while clicking the macro names.)

2. Click the "Copy" button. The macros should now be displayed in the left window as being in your new template. (You can also delete or rename macros if you like.)

3. Click the "Close" button.

4. Save your new template, which now contains the macros you copied to it.

You've just created your own add-in template containing your own macros.

Adding a Template Automatically

In upcoming issues of Editorium Update, I'll explain how to run macros by adding your own toolbar buttons, menu items, and keyboard combinations to Microsoft Word. If you want to get a head start, however, be sure to read today's Readers Write column, where subscriber David M Varner explains the importance of using keyboard combinations ("hot keys") and how to create them. Thanks, David!

Last week I explained how to add macros to Microsoft Word in a "global template" or "add-in." You can read last week's newsletter here:

http://www.topica.com/lists/editorium/read/message.html?mid=1707012536

The problem is, every time you start Word, you'll have to reactivate the global template before you can use its macros. Here's the procedure:

1. Click the "Tools" menu (the "File" menu in earlier versions of Word).

2. Click "Templates and Add-ins" ("Templates" in earlier versions of Word).

3. In the list of global templates and add-ins, put a checkmark in the checkbox for the template you want to use.

4. Click the "OK" button.

Wouldn't it be nice, though, if you could have Word add the template automatically? You can. Just follow this procedure:

1. Close Microsoft Word.

2. Copy the template you want to add automatically.

3. Navigate to Word's Startup folder.

4. Paste the template into the Startup folder.

5. Restart Microsoft Word.

The macros in the template should now be available for you to use, and they'll be available automatically every time you start Word.

If you don't know where the Startup folder is, here's how to find out:

1. Click the "Tools" menu (in any version of Word).

2. Click the "Options" menu item.

3. Click the "File Locations" tab.

You'll see the location of the Startup folder on the line labeled "Startup." (If you can't see the full path to the folder, click the "Modify" button.)

_________________________________________

READERS WRITE

David M Varner wrote:

Thank you for your recent information on macros. They are a big key to saving critical time on editorial tasks. I know that my assignments frequently incur midstream revisions; more accurately, frequent revisions (to subject matter as well as format) are the rule. So while macros may take a little time to create, you can zoom through those revisions so quickly that it is well worth knowing this function well. Glad to see your focus on macros.

I disagree, however, with your implicit vote for using Word's menu to implement macros. Sorting through menu items is generally somewhat awkward, especially with time constraints always looming. A pretty good short circuit for this snare is to use hot keys. Even if you prefer mousing in the menu, hot keys are a wonderful snap by comparison when considering time, and possibly crucial when a deadline is close. Having a stable of custom macros is not a bad idea either, if not inevitable.

Not only can you choose to assign hot keys while you are creating a macro, but you can also create hot keys for existing macros. I discovered the latter a couple of years ago while trying to remember the hot keys I had assigned to a certain macro. To my dismay, the answer was not to be found in the Macros dialog box--a strange oversight.

This oversight was so strange, in fact, I was convinced that macro hot-key assignments still must exist somewhere. Well, they do, and their location was not obvious, but not too far away. In short, I found them in the "Customize" dialog box. So, to find the forgotten hot keys you assigned to a macro:

1. Click "Tools" on the menu, then select "Customize" to access the "Customize" dialog box.

2. Click the "Keyboard" button to access the "Customize Keyboard" dialog box.

3. In the "Categories" field, scroll down to and select "Macros."

4. In the "Macros" field, scroll, if necessary, down to the macro you want and select it. Your assigned hot keys now appear in the "Current keys" field.

You can probably now figure out how to assign (or modify) hot keys to existing macros using the "Customize Keyboard" dialog box: Using the "Press new shortcut key" field, select "Ctrl," "Alt," and/or "Shift" keys in combination with other keyboard characters to make that hot-key assignment.

Using "Found" Macros

Over the past few weeks we've been talking about recording macros to automate repetitive tasks in Microsoft Word. You can read the newsletters here:

http://www.topica.com/lists/editorium/read/message.html?mid=1706651129

http://www.topica.com/lists/editorium/read/message.html?mid=1706748016

http://www.topica.com/lists/editorium/read/message.html?mid=1706832239

What you may not know is that there are lots of "prerecorded" macros that will do all kinds of neat things. For example, subscribers to the Word-PC email list often post useful macros. You can learn more about the list (and search the list archives) here:

http://listserv.liv.ac.uk/archives/word-pc.html

You can also find macros on the Web by searching for the keywords "microsoft word macro" in your favorite search engine.

The macros you find will probably look something like this:


Sub CopyToSpike
If WordBasic.GetSelStartPos() <> _
WordBasic.GetSelEndPos() Then 'Text is selected
WordBasic.Spike 'Add entry to spike
WordBasic.EditUndo 'Undo the cut
Else
WordBasic.MsgBox "Please select text before running this macro.", _
"No Text Selected"
End If
End Sub

That particular macro copies text to the Spike. You can learn more about it here:

http://www.topica.com/lists/editorium/read/message.html?mid=1701697740

However, you don't have to understand how the macro works in order to use it. Here's how to put it (or any other macro) into Microsoft Word so it will be available when you need it:

1. Copy the text of the macro, starting with the first "Sub" and ending with the last "Sub." If the macro doesn't have those "Sub" lines at the beginning and end, skip step 8 in these instructions.

2. Click the "Tools" menu at the top of your Microsoft Word window.

3. Click "Macro."

4. In Word 97 or later, click "Macros."

5. Make sure "Macros Available In" shows "Normal.dot."

6. Type a name for the macro in the "Macro Name" box--probably the name used after the first "Sub." For this macro, that's "CopyToSpike."

7. Click "Create."

8. Delete the "Sub [macro name]" and "End Sub" lines that Word created in the macro window. The macro window should now be completely empty.

9. Paste the macro text at the current insertion point.

10. In Word 6 or 7, click "File," then "Close," then "Yes." In Word 97 or later, click "File," then "Close and Return to Microsoft Word."

The macro is now stored in your Normal template, ready for use.

To actually run the macro, do this:

1. Click the "Tools" menu.

2. Click "Macro."

3. In Word 97 or later, click "Macros."

4. Click the name of your macro to select it.

5. Click the "Run" button. (If you wanted to delete the macro, you could press the "Delete" button instead.)

And now, some cautions:

1. Make sure the macro was created for the version of Word you are using. Macros created for Word 97 and later versions will not run in earlier versions, and you can't just paste macros written for earlier versions into Word 97 and later. Also, later versions of Word have certain features that earlier versions don't, so a macro that uses features specific to Word 2000 won't run in Word 97.

2. Try to make sure the macro comes from a reasonably reliable source.

3. Before using a macro on a real document, test it on a backup copy of the document to *make sure* it does what you need it to do.

_________________________________________

READERS WRITE

Subscriber Meg Cox wrote:

Newly committed to automating whatever I can, I tried to automate changing a word or phrase in quotes to italics and removing the quotes. But with wildcards turned on, Find wouldn't find quotation marks at all. Any idea of where I might be going wrong?

I responded (in summary):

If your document has curly quotes, use ^0147 (for opening) and ^0148 (for closing). Those are the ANSI codes for curly quotation marks. If your document has straight quotes, use " in your find and replace.

As I tested this, I used this string in the Find What box:

"(*)"

And this string in the Replace With box (formatted as italic):

1

Or, if you have curly quotes, you could find this:

^0147(*)^0148

And replace with the same thing (formatted as italic):

1

This will cause you trouble if you have unmatched quotation marks. If that's the case, you might need to do something like this:

"([!"]@)"

Or this:

^0147([!^0147]@)^0148

Recording a Complex Macro

[Editor's note: This week's article is the third in our series on macros, and I'm honored to have written it with Dan A. Wilson, proprietor of The Editor's DeskTop (http://www.editorsdesktop.com/). The example in the article is intentionally contrived. It's a nightmare task of repetitive processes. And it's long. But it's designed to teach you some things about recording macros. Dan and I hope you find it enlightening.]

The title "Recording a Complex Macro" looks intimidating, but actually *recording* a complex macro isn't really that hard. You just have to get firmly in mind what you want to do, step by step, and then do it.

~~~~~~~~~~~~

THE SCENARIO

~~~~~~~~~~~~

Suppose you have a Word document to edit--a 350-page dissertation with the title *Derived Humor: On the Roots of George Carlin's Comedy in the Works of Mark Twain.* The document has no block quotations, but it does have two hundred short Twain quotations and two hundred short Carlin quotations. The project editor wants you to make two lists of quotations so a couple of drudges can verify their accuracy. She wants the Twain quotations in one list and the Carlin quotations in another.

You'll have to create two new, blank documents. Save one with the name Twain and the other with the name Carlin. Twain will (eventually) contain all of the Twain quotations, and Carlin will (eventually) contain all of the Carlin quotations. After creating your new files, you'd have to do this (if you were doing the work by hand):

1. Scan through the dissertation file and find every Twain or Carlin quotation.

2. Select it (with its source citation).

3. Copy it to the clipboard.

4. Switch to Twain or Carlin, as appropriate.

5. Paste the quotation and source citation.

6. Hit ENTER to jump down a line so you're ready to paste the next quotation.

7. Switch back to the dissertation and hunt for the next quotation.

Whew! You'd have to select four hundred quotations, copy four hundred times, switch documents four hundred times, paste four hundred times, hit ENTER four hundred times, and switch back to your dissertation four hundred times. It would take you forever, and you'd have RSI pain before you were done.

Well, suppose we reduce that list to two tasks:

1. Select four hundred quotations (still a lot of work, but bear with us).

2. Record two macros that will do everything else when we hit their keyboard shortcuts.

That should reduce the time required for the job by at least eighty percent--maybe ninety! Not bad for a few seconds of macro recording.

Since we're going to select the quotations by hand, items 3 through 7 in the list above will make up the steps of our Twain macro:

3. Copy the quotation and citation to the clipboard.

4. Switch to Twain.

5. Paste the quotation and source citation.

6. Hit ENTER to jump down a line so you're ready to paste the next quotation.

7. Switch back to the dissertation and hunt for the next quotation.

~~~~~~~~~~~~~~~~~~~~~~~~~

RECORDING THE FIRST MACRO

~~~~~~~~~~~~~~~~~~~~~~~~~

You've got three documents open, right?

1. The dissertation itself. (We recommend that you actually create such a document to use while working through these instructions. It can include a bunch of junk text with the sample quotations from this article pasted here and there so you can actually see what happens when you record and use these macros.)

2. The empty Twain document.

3. The empty Carlin document.

You can check this by clicking the "Windows" menu on Word's menu bar, which should display a drop-down menu listing the three documents. You can switch to any of the documents by clicking its name on the menu. For now, switch to the dissertation, our starting place, and select the first Twain quotation:

"God, if you forgive my little jokes on thee, I'll forgive your great big joke on me" (ATS, p. 35).

With the quotation selected, let's record our first macro:

1. Click the "Tools" menu.

2. Click "Macro."

3. Click "Record New Macro" (in older versions of Word, click the "Record" button).

4. Type a name for the macro ("Twain") in the "Macro name" box.

5. Under "Assign macro to," click the "Keyboard" button.

6. With your cursor in the "Press new shortcut key" box, press the function key or key combination you want to use to run the macro, such as SHIFT + CTRL + T (for Twain).

7. Click the "Assign" button.

8. Click the "Close" button. The macro recording toolbar will appear with two buttons--the first to stop recording and the second to pause recording if you need to. That means the macro recorder is now recording what you do.

9. Copy the quotation and citation to the Clipboard by pressing CTRL + c.

10. Switch to the Twain document by clicking the "Windows" menu and then clicking "Twain."

11. Paste the quotation and citation by pressing CTRL + v.

12. Hit ENTER to jump down a line so you're ready to paste the next quotation.

13. Switch back to the dissertation by clicking the "Windows" menu and then clicking "Dissertation."

14. Click the "Stop" button (the button with the blue square) on the macro recording toolbar to stop recording.

~~~~~~~~~~~~~~~~~~~~~~~~~~

RECORDING THE SECOND MACRO

~~~~~~~~~~~~~~~~~~~~~~~~~~

Now let's get ready to record our Carlin macro. In the dissertation, select the first Carlin quotation:

"One tequila, two tequila, three tequila, floor" (BFP, p. 29).

With the quotation selected, let's record our second macro:

1. Click the "Tools" menu.

2. Click "Macro."

3. Click "Record New Macro" (in older versions of Word, click the "Record" button).

4. Type a name for the macro ("Carlin") in the "Macro name" box.

5. Under "Assign macro to," click the "Keyboard" button.

6. With your cursor in the "Press new shortcut key" box, press the function key or key combination you want to use to run the macro, such as SHIFT + CTRL + C (for Carlin).

7. Click the "Assign" button.

8. Click the "Close" button. The macro recording toolbar will appear with two buttons--the first to stop recording and the second to pause recording if you need to. That means the macro recorder is now recording what you do.

9. Copy the quotation and citation to the Clipboard by pressing CTRL + c.

10. Switch to the Carlin document by clicking the "Windows" menu and then clicking "Carlin."

11. Paste the quotation and citation by pressing CTRL + v.

12. Hit ENTER to jump down a line so you're ready to paste the next quotation.

13. Switch back to the dissertation by clicking the "Windows" menu and then clicking "Dissertation."

14. Click the "Stop" button (the button with the blue square) on the macro recording toolbar to stop recording.

~~~~~~~~~~~~~~~~~~

RUNNING THE MACROS

~~~~~~~~~~~~~~~~~~

Now, with both macros recorded, we're ready to go to work. Here's the procedure:

1. In the dissertation document, select a quotation, either by Twain or by Carlin.

2. If the quotation is by Twain, press SHIFT + CTRL + T.

3. If the quotation is by Carlin, press SHIFT + CTRL + C.

4. Keep going until all of the quotations are done.

When you're finished, your Twain document will have all of the Twain quotations, and the Carlin document will have all of the Carlin quotations.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

AUTOMATICALLY SELECTING THE QUOTATIONS

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Still too much work? Let's see if we can get the macros to select the quotations automatically.

We'll start with the Twain quotations. What do they have in common? They're all in quotation marks, and they're all followed by an ATS source citation in parentheses. If you've read our wildcard articles over the past few months, you know we could find (and thus automatically select) those quotations with this wildcard string:

"[!"]@" (ATS*).

What's that mean?

" is a quotation mark (which opens a quotation).

[!"]@ means "Find any additional characters except a quotation mark." (We need this to keep from including parts of other quotations.)

" is another quotation mark (which closes a quotation).

Then there's a space.

( represents an opening parenthesis. (Remember, since a parenthesis is itself a wildcard, we have to use a backslash to tell Word to treat this one as a character.)

ATS is our Twain source.

* represents any other characters following the source.

) represents a closing parenthesis.

Finally, there's a period.

Taken together, this string of characters will find our Twain quotation and others like it. And we can do the same thing with our Carlin quotations, using BFP rather than ATS in our wildcard string. So let's record our macros again, this time including this fancy way of finding and selecting them. Remember, you'll need to have three documents open:

1. The dissertation itself.

2. The empty Twain document.

3. The empty Carlin document.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~

RE-RECORDING THE FIRST MACRO

~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Then, with the dissertation as the active document, follow this procedure:

1. Click the "Tools" menu.

2. Click "Macro."

3. Click "Record New Macro" (in older versions of Word, click the "Record" button).

4. Type a name for the macro ("Twain") in the "Macro name" box. If Word asks if you want to replace the existing macro, click "Yes."

5. Under "Assign macro to," click the "Keyboard" button.

6. With your cursor in the "Press new shortcut key" box, press the function key or key combination you want to use to run the macro, such as SHIFT + CTRL + T (for Twain).

7. Click the "Assign" button.

8. Click the "Close" button. The macro recording toolbar will appear with two buttons--the first to stop recording and the second to pause recording if you need to. That means the macro recorder is now recording what you do.

9. Click the "Edit" menu.

10. Click the "Find" menu item.

11. In the Find dialog's "Find What" box, enter the string we discussed:

"[!"]@" (ATS*).

12. Put a checkmark in the "Use wildcards" or "Use Pattern Matching" checkbox. (You may need to click the "More" button before this is available.)

13. Click the "Find Next" button. Word will find and select the first Twain quotation and citation.

14. Click the "Cancel" button to close the Find dialog.

15. Copy the quotation and citation to the Clipboard by pressing CTRL + c.

16. Switch to the Twain document by clicking the "Windows" menu and then clicking "Twain."

17. Paste the quotation and citation by pressing CTRL + v.

18. Hit ENTER to jump down a line so you're ready to paste the next quotation.

19. Switch back to the dissertation by clicking the "Windows" menu and then clicking "Dissertation."

20. Click the "Stop" button (the button with the blue square) on the macro recording toolbar to stop recording.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

RE-RECORDING THE SECOND MACRO

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Again, with the dissertation as the active document, follow this procedure:

1. Click the "Tools" menu.

2. Click "Macro."

3. Click "Record New Macro" (in older versions of Word, click the "Record" button).

4. Type a name for the macro ("Carlin") in the "Macro name" box. If Word asks if you want to replace the existing macro, click "Yes."

5. Under "Assign macro to," click the "Keyboard" button.

6. With your cursor in the "Press new shortcut key" box, press the function key or key combination you want to use to run the macro, such as SHIFT + CTRL + C (for Carlin).

7. Click the "Assign" button.

8. Click the "Close" button. The macro recording toolbar will appear with two buttons--the first to stop recording and the second to pause recording if you need to. That means the macro recorder is now recording what you do.

9. Click the "Edit" menu.

10. Click the "Find" menu item.

11. In the Find dialog's "Find What" box, enter this string:

"[!"]@" (BFP*).

12. Put a checkmark in the "Use wildcards" or "Use Pattern Matching" checkbox. (You may need to click the "More" button before this is available.)

13. Click the "Find Next" button. Word will find and select the first Carlin quotation and citation.

14. Click the "Cancel" button to close the Find dialog.

15. Copy the quotation and citation to the Clipboard by pressing CTRL + c.

16. Switch to the Carlin document by clicking the "Windows" menu and then clicking "Carlin."

17. Paste the quotation and citation by pressing CTRL + v.

18. Hit ENTER to jump down a line so you're ready to paste the next quotation.

19. Switch back to the dissertation by clicking the "Windows" menu and then clicking "Dissertation."

20. Click the "Stop" button (the button with the blue square) on the macro recording toolbar to stop recording.

~~~~~~~~~~~~

FINISHING UP

~~~~~~~~~~~~

Now you can go through the dissertation pressing SHIFT + CTRL + T to automatically select and copy the Twain quotations and then pressing SHIFT + CTRL + C to automatically select and copy the Carlin quotations. It will still take some time, but it will be *much* faster than doing all of the work by hand. Most important, by going through all of this, you've probably learned quite a bit about how to record macros and use them to simplify your work. And that's what we were *really* trying to accomplish.

Recording a Find-and-Replace Macro

Today's article is the second in our series about recording macros. It covers basically the same procedure as last week's newsletter, but with an emphasis on finding and replacing problem items in an electronic manuscript. Watch for a complex (and useful) example of recording a macro in next week's article, coauthored with Dan A. Wilson, proprietor of The Editor's DeskTop (http://www.editorsdesktop.com/).

If you've been editing in Microsoft Word, you've probably come up with a list of items you find and replace on every manuscript. These might be picky little things like replacing multiple spaces with a single space, replacing underlining with italic, or replacing the word "catalogue" with "catalog" (or vice versa). If you're now doing such replacements manually, one after the other, you could record them all as a macro that you could run on any manuscript that needs it, saving yourself many hours over the course of a year. To do so, just follow the basic procedure outlined in last week's newsletter:

1. Start Word's macro recorder.

2. Do the stuff you want to record--in this case, find and replace all of the items on your list.

3. Stop the macro recorder.

(You can read last week's newsletter here: http://www.topica.com/lists/editorium/read/message.html?mid=1706651129.)

Got your list? Let's do it (on some junk files, of course):

1. START THE MACRO RECORDER

a. Click the "Tools" menu.

b. Click "Macro."

c. Click "Record New Macro" (in older versions of Word, click the "Record" button).

d. Type a name for your macro (something like "ReplaceMyStuff") in the "Macro name" box. (You can't use spaces in a macro name.)

e. Click the "OK" button. The macro recording toolbar will appear with two buttons--the first to stop recording and the second to pause recording if you need to. That means the macro recorder is now recording what you do.

2. DO THE STUFF YOU WANT TO RECORD

Here's where you're going to find and replace all of those items on your list:

a. Go to the top of your document by pressing CTRL + HOME.

b. Click the "Edit" menu.

c. Click "Replace."

d. In the "Find What" box, type the string of characters or set the formatting you want to find. You can use wildcard strings if you like, as explained in Editorium Update over the past several issues. For example, if you wanted to find multiple spaces (to be replaced by a single space), you could enter a space followed by {2,} (which means "at least two") and then put a checkmark in the "Use Wildcards" (or "Use pattern matching") checkbox (you might have to click the "More" button before the checkbox is visible).

e. In the "Replace With" box, type the string of characters or set the formatting you want to use to replace the contents of the "Find What" box. For example, if you wanted to replace multiple spaces with a single space, you'd enter a single space.

f. Click "Replace All."

Now repeat those steps for each item you want to find and replace, setting the options and checkboxes in the Replace dialog as needed. (For a wonderfully useful example of transposing dates in a find-and-replace macro, see today's Readers Write column following this article.)

As you replace your items, don't forget that you're recording what you do. It's easy to get sidetracked and start editing, which would create a very strange (and potentially dangerous!) macro indeed. Resist the temptation. Just mechanically find and replace your items, one at a time. Don't think about anything else. *Be* the computer.

If you do make a mistake, don't panic. Just press CTRL + Z to undo the last find-and-replace operation. Your macro will record that, too, so no damage will be done, although your macro will later take longer to run because it includes that unnecessary find-and-replace operation and its reversal. Of course, you can always start over again if you really need to.

3. STOP THE MACRO RECORDER

a. Click the "Stop" button (the button with the blue square) on the macro recording toolbar to stop recording.

That's it! You've recorded a macro to find and replace all those items you've been cleaning up manually. To play it back:

1. Click the "Tools" menu.

2. Click "Macro."

3. In Word 97 or later, click "Macros."

4. Click the name of your macro to select it.

5. Click the "Run" button. (If you wanted to delete your macro, you could press the "Delete" button instead.)

All of the items you recorded will be fixed automatically.

If the items you want to find and replace are fairly complicated (using wildcards, for example), you should try each one by hand and make sure it's working correctly before recording your macro.

If you don't have a list of items you regularly need to clean up, you might consider making one. As you edit your next project, just make a note every time you come across something you need to change more than a couple of times. Then use your list to record a find-and-replace macro that will do the work for you from now on.

Got that macro running? Sit back and sip your diet Coke. Life is sweet.

If you like the idea of cleaning up nitpicky items with a macro, you may be interested in our FileCleaner program, which you can learn about here:

http://www.editorium.com/14845.htm

If you'd like to run your macro on a bunch of documents all at once, you may be interested in our MultiMacro program, which you can learn about here:

http://www.editorium.com/14844.htm

_________________________________________

READERS WRITE

~~~~~~~~~~~~~~~~~

Transposing Dates

~~~~~~~~~~~~~~~~~

Subscriber Meg Cox wrote:

I just set up my first wildcard combination for a search and replace, and it works! I figured now was the time to take my walk on the wild side because I have a manuscript full of dates that are styled every which way. Now here's my question: I came up with the following to change various versions of month/day/year to day/month/year--but only for January.

Find what: (Ja[.a-z]@) ([0-9]{1,2}), ([0-9]{4})

Replace with: 2 January 3

I'd like to use this for all dates. I wonder if there's something like that [andh] combination that I can use to capture pairs of letters that begin months: Ja, Fe, Ma, Ap, and so on. But then again, maybe it won't work because I won't be able to specify the proper month in the "Replace with" box. This looks like the perfect opportunity to learn to do macros. Is a macro indeed the only one-click solution here?

I responded (in summary):

You're right--there's no easy way to do this with one click. You might consider recording a macro to do all of the combinations. Once you have it recorded, you can use it whenever you need it:

1. Click the "Tools" menu.

2. Click "Macro."

3. Click "Record New Macro."

4. Type a name for your macro (something like "TransposeDates") in the "Macro name" box.

5. If you want, assign the macro to a toolbar or keyboard combination.

6. Click the "OK" button. (The macro recording toolbar will appear.)

7. Record the Replace routine for each month. In other words, run your Replace routine for January, then for February, and so on.

8. Click the "Stop" button (the button with the blue square) on the macro recording toolbar.

In other words:

1. Start recording your macro.

2. Do the search-and-replace for January.

3. Do the search-and-replace for February.

4. Do the search-and-replace for March.

5. And so on through December.

6. Stop recording your macro.

Now, if you assigned the macro to a toolbar or key combination, you can use the toolbar or key combination to run the macro in the future. Or, you can do this:

1. Click the "Tools" menu.

2. Click "Macro."

3. Click "Macros."

4. Click the name for your macro (say, "TransposeDates") in the list of macros so it's selected.

5. Click the "Run" button.

That should do the job.

At this point, you'll have transposed all of the dates in the current document. But you'll also have created a macro that you can run in one step on any document in the future--a very handy thing to have.

After responding to Meg, I realized that there is one possible way to do what she was asking--transpose all of the dates in one fell swoop--*if* all of the months have been spelled out. Consider this wildcard string:

([JFMASOND][a-z]@) ([0-9]{1,2}), ([0-9]{4})

[JFMASOND] represents the first letter of each month, with duplicate letters removed.

[a-z]@ represents lowercase letters following the capital letter that starts the word.

There's a space after the name of the month.

[0-9]{1,2} represents the day of the month, whether one or two digits.

There's a comma and a space after the day.

[0-9]{4} represents four consecutive digits--in other words, the year.

The parentheses group the items so you can transpose them using "Find What Expression" wildcards in the "Replace With" box (after turning on "Use Wildcards," of course):

2 1 3

If some of the months have been abbreviated (Jan., Feb., Mar., etc.), you could transpose them by finding this (notice the period following the @ sign):

([JFMASOND][a-z]@.) ([0-9]{1,2}), ([0-9]{4})

and replacing with this:

2 1 3

If you've got a mix of abbreviated and unabbreviated dates, this string will find them all:

([JFMASOND][.a-z]@) ([0-9]{1,2}), ([0-9]{4})

and you can transpose them with this replacement string:

2 1 3

But of course, that won't spell out the abbreviated months. To do that, you'd need to record a macro that finds and replaces each month.

If you're going to use any of these wildcard strings, be sure to run them on some test documents to make sure they do what you need--and *don't* do what you don't need.

Macro Recording: The Basics

Over the next few weeks Editorium Update will explain how to record macros and use them to simplify repetitive editorial tasks in Microsoft Word. I'd like to thank subscribers Meg Cox, Allene Goforth, and Dan A. Wilson for suggesting this topic. I'm especially grateful to Dan, who is an editor's editor and Microsoft Word expert, for writing one of the articles with me. (Dan is the proprietor of The Editor's DeskTop, http://www.editorsdesktop.com/.) At Dan's suggestion, I'll start with the basics, get a little fancier next week, and then show you Dan's backbreaker of an example two weeks from now, so stay tuned. If you're a member of the Freelance email list who signed up for this series of articles, welcome! I hope you'll find the newsletter valuable enough to stay with us. If you've been reading the past newsletters on searching with wildcards, you'll want to look at our Readers Write column after the feature article for some additional information.

Macros--the mysterium tremendum, the sanctum sanctorum of Microsoft Word. Or, hey, just a great way to automate those mind-numbing, finger-breaking tasks you've been doing manually for so long. Recording a macro is like recording a song from the radio, only you're recording keystrokes instead of music. Here's the basic procedure:

1. Start the macro recorder (just like starting your tape recorder).

2. Do the stuff you want to record (such as typing text and running Word features).

3. Stop the macro recorder (just like stopping your tape recorder).

Well, shoot, that's not so hard.

Now let's take a simple but real (and useful) example. As you edit, you probably transpose characters a lot--I know I do. But it takes several keystrokes to do it:

1. Select the character you want to move. (Hold down SHIFT and press the RIGHT ARROW key.)

2. Cut the character. (Hold down CTRL and press X.)

3. Move to the place you want to put the character. (Press the LEFT ARROW key.)

4. Paste the character. (Hold down CTRL and press V.)

That's seven keystrokes altogether--keystrokes you do over and over, all of the time. Let's make life easier by recording them in a macro:

1. START THE MACRO RECORDER

a. Click the "Tools" menu.

b. Click "Macro."

c. Click "Record New Macro" (in older versions of Word, click the "Record" button).

d. Type a name for your macro (something like "TransposeCharacters") in the "Macro name" box. (You can't use spaces in a macro name.) If you're using our Editor's ToolKit or Editor's ToolKit Plus program, don't call the macro "TransposeCharacters," as our programs already use that name.

e. Under "Assign macro to," click the "Keyboard" button.

f. With your cursor in the "Press new shortcut key" box, press the function key or key combination you want to use to run the macro. I like function key 12 (F12) for this macro, but you can use CTRL + T (for "Transpose") or something else. Word will show you if the key or key combination is already assigned. If it is, you can try a different one or overwrite the current assignment. It's up to you. You may want to avoid combinations using the ALT key, which works with various letters to activate menu items and dialog controls. You can, however, use ALT + CTRL, ALT + SHIFT, or SHIFT + CTRL as part of your combination.

g. Click the "Assign" button.

h. Click the "Close" button. The macro recording toolbar will appear with two buttons--the first to stop recording and the second to pause recording if you need to. That means the macro recorder is now recording what you do.

2. DO THE STUFF YOU WANT TO RECORD

a. Select the character you want to move. (Hold down SHIFT and press the RIGHT ARROW key.)

b. Cut the character. (Hold down CTRL and press X.)

c. Move to the place you want to put the character. (Press the LEFT ARROW key.)

d. Paste the character. (Hold down CTRL and press V.)

Notice that this is the same procedure we used previously when we *weren't* recording a macro. In other words, we transposed the two characters just as we ordinarily would. Be careful not to use the cursor keys to move to a certain character before following this procedure. If you do, those keystrokes will become *part* of the procedure, and you'll end up recording all of those cursor movements. The idea is to record only the keystrokes you want the macro to do for you.

3. STOP THE MACRO RECORDER

a. Click the "Stop" button (the button with the blue square) on the macro recording toolbar to stop recording.

That's it! You've recorded a macro. Now let's play it back:

1. Put your cursor between two characters you want to transpose.

2. Click the "Tools" menu.

3. Click "Macro."

4. In Word 97 or later, click "Macros."

5. Click the name of your macro to select it.

6. Click the "Run" button. (If you wanted to delete your macro, you could press the "Delete" button instead.)

That's one way to play back your macro. But since you assigned a key combination to the macro, it's a lot easier to do it like this:

1. Put your cursor between two characters you want to transpose.

2. Press the function key or key combination you've assigned to run the macro.

Presto! The two characters will be transposed.

In a way, what you've just done is create a feature (Transpose Characters) that Microsoft Word didn't have before. Are you beginning to see the possibilities?

You can learn more about Editor's ToolKit and Editor's ToolKit Plus, which have lots of handy macros like this one, here:

http://www.editorium.com/14842.htm

http://www.editorium.com/14857.htm

_________________________________________

READERS WRITE

~~~~~~~~~~~~~~~~~~~~~~

Wildcard Inconsistency

~~~~~~~~~~~~~~~~~~~~~~

Allene Goforth (agoforth@Aros.Net) discovered an interesting inconsistency in how wildcards are handled from one version of Microsoft Word to another. She wrote:

I finally started working on the wildcards yesterday. Everything was progressing smoothly until I got to Gandhi. I typed in Ghandi Gahndi Ganhdi and then I tried to change those to Gandhi, using G[andh]{3}i but it can't even find the above string--let alone change them.

[Allene was referring to our newsletter of March 28, 2001, which you can read here: http://www.topica.com/lists/editorium/read/message.html?mid=1706069286.]

G[andh][andh][andh][andh]i worked as did G[andh]@i so what am I doing wrong?

I responded (after doing some testing):

The string you are using--

G[andh]{3}i

--works great in Word 95, which is the version of Word I ordinarily use.

However, as you've learned, in Word 2000 it doesn't work. Instead, you have to use this:

G[andh]{4}i

In other Words, the wildcards seem to work differently in different versions of Word.

In Word 95, {3} means "three *more* of the previous expression."

In Word 2000, {3} means "*three* of the previous expression." Or so it seems.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Finding ANSI Codes on a Macintosh

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Erika Buky (erikab@socrates.Berkeley.edu) found what seems to be a bug when searching for ANSI codes on a Macintosh. She wrote:

I've been reading the newsletters on wildcards with great interest and amazing my friends with my wizardry. I've noticed one problem, however, in trying to apply your clever solutions for transposing first names and last names in lists, and so on--things that require use of a code for a paragraph break.

[Erika was referring to our newsletter of April 18, 2001, which you can read here: http://www.topica.com/lists/editorium/read/message.html?mid=1706365638.]

I'm using Word 98 on a Mac (OS 8.1), and the code ^013 for a paragraph break seems to work only sporadically. When I'm doing searches like the one above, which requires this code at the end of the second search expression--^013([A-z]@) ([A-z]@)^013--the replace operation fails, I think because the paragraph break code is not recognized. (Word selects the first name, the space, and the first 2 letters of the second name, a string which meets the search criteria if you ignore the paragraph break code.)

Codes like ^09 for tabs are also treated inconsistently; sometimes I've had better luck dropping the initial zero.

Any idea why this might be so? Any possible solutions?

I responded:

I've just done some testing, and this seems to me to be a bug in Word. In both Word 98 and 2001 (on the Mac, of course), ^013 is recognized *unless* you specify that you're using wildcards. Then Word doesn't find the paragraph mark. Try searching for ^013 (or ^13) all by itself with the "Use wildcards" checkbox turned off and then on, and you'll see what I mean.

The Word 2001 documentation specifically says to use ^13 rather than ^p when using wildcards, but when you actually try it, it doesn't work. This is a real problem for Mac users, because it means there's no way to search for paragraph returns when using wildcards--unless you use a two-step operation. For example, with "Use wildcards" turned off, you could replace ^p with

^p

(the

being an arbitrary code) and then (with "Use wildcards" turned on) searching for

([A-z]@) ([A-z]@)

.

Thanks to Allene and Erika for their questions.