M2Ktech.com


Bookmark
Page

   TECH FORUM
 
Forum
FORUM
Tips to your desktop
Subscribe to our mailing list:
Email:

Search this site:

<< BACK

PRINT VERSION

Making Life Easier with Macros

If you are one of our many readers who use a word processor regularly, there will be certain routines that you find yourself repeating over and over again. Any of these repetitive routines that involve several steps could most likely benefit from being put into a macro. Once the macro is created, you can perform the routine with a simple key combination or by selecting the macro from a menu or toolbar. The more complex the routine, the greater the benefit from the macro. You probably knew this already but may have thought creating a macro was too difficult. It’s actually quite easy.

In essence, a macro is a shortcut. Creating one involves turning on the macro recorder and then doing the routine that you want the macro to do. Then, you turn the recorder off and save the macro. The macro is now a command that will repeat all of the recorded keystrokes and mouse clicks whenever you run it.

Some of the actions that lend themselves to useful macros include:

  • Formatting of text, borders or backgrounds
  • Insertion of tables, logos or other graphics into a document
  • Compiling indexes or Tables of Contents with customized settings
  • Changing settings that are buried deep in submenus or dialog boxes
  • Mail merges and other complex but repetitive tasks

There are many others as well, and some may be unique to your operation. Anything you do that requires a series of steps is a candidate for a macro, if you find yourself doing the same steps on multiple occasions.

Before we go step-by-step through creating a macro in Microsoft Word, there is one little catch. The macro recorder will pick up mouse clicks but not mouse movements, so you must use keyboard shortcuts for moving the insertion point, selecting text, etc. With that warning out of the way, let’s create a macro for ending off a letter.

  1. Open an old letter document (or create a new one), and delete everything after the end of the last paragraph of text. The cursor should be sitting right there after the period of the last sentence.

  2. Go to the Tools menu and select Macro, and then Record a New Macro. This will open the Record Macro dialog box shown here.


  3. Give the macro a name up to 80 characters long (we called ours ‘Ending’). The name can include an underscore but no spaces, and it can contain numbers but must start with a letter.

  4. You will probably want to store your macro in the default Normal template (Normal.dot), but if not, change it. A description is optional.

  5. Click the Keyboard icon to assign a keyboard shortcut to this macro. This will open the Customize Keyboard window.



  6. Type the key shortcut you want. We used Alt+E, but it will tell you if your choice is already in use for something else. Next, click Assign, and then Close.

  7. A little toolbar pops up with two buttons: one to stop recording and one to pause. At this point you are actually recording your macro.

  8. Hit the Enter key twice and then type Sincerely,. Press the Enter key three more times and type in your name.

  9. Click the Stop button on the macro toolbar. Your macro is now finished and ready for use.

  10. To try it out, delete your work, so that the cursor is once more at the end of the text. Press Alt+E (or whatever key combination you chose) and you will see Word magically type in an ending to your letter.

This shortcut for ending your letters will now be available in any Word document that uses the Normal template.

If you don’t want to save it, go to Tools – Macro again and select Macros from the submenu. Find your macro on the list, select it and click Delete. Before you delete it though, you might want to select Edit instead and you can see what a Visual Basic script looks like. That’s what macros actually are, and if you know how to script in Visual Basic you can do things with macros that go far beyond just recording keystrokes.

Of course, this macro we’ve made is rather simplistic and most of them will contain more steps, but the principles are the same. Here are some tips that might help in the longer ones.

  1. Think through the steps required for the action you want to do. It might even be worth doing a practice run before you start recording anything, and pay particular attention to any steps that involve mouse movements so you can figure out the keyboard substitutes. This includes text selection, drag-and-drop, etc.

  2. If your document will be saved as an HTML web page rather than a .doc file, macros must be created with the Microsoft Script Editor rather than the keystroke recorder. That’s beyond the scope of this tech tip, but we just wanted you to know.

  3. Notice if your macro must execute at a specific point in the document. For instance in the macro we just did, we probably should have begun by typing Ctrl+End to make sure the cursor was positioned at the end of the text. As it is now, if the cursor is in the middle of the text and you press Alt+E, guess where ‘Sincerely’ will appear?

  4. If you enter settings in a dialog box, the macro records all of the settings, not just the ones you entered, and all of them will be applied when you run the macro.

  5. If you change a toggle setting, the macro will toggle the setting each time it runs, no matter which state it’s in to start with. If you’re not paying attention, this fact and the one in #4 can sometimes give you surprising results.

That’s all for this week. It certainly isn’t everything there is to know about macros, but it should give you a useful start.

Disclaimer - The Micro 2000 Tech Tip is a free service providing information only. While we use reasonable care to see that this information is correct, we do not guarantee it for accuracy, completeness or fitness for a particular purpose. Micro 2000, Inc. shall not be liable for damages of any kind in connection with the use or misuse of this information.

Micro-Scope - PC Hardware trouble shooting at your finger tips

Micro2000 PC Diagnostics

Erased the data on your hard drive? Think again!

MicroScope on a Stick





Free translation
   SITEMAP | CONTACT | HOME

Disclaimer - The M2K Tech Tip is a free service providing information only. While we use reasonable care to see that this information is correct, we do not guarantee it for accuracy, completeness or fitness for a particular purpose. M2KTech.com shall not be liable for damages of any kind in connection with the use or misuse of this information.

© 2006 M2Ktech.com All Rights Reserved