Saturday, November 10, 2007

Cut out the labour, use macros

OFTEN you find yourself repeating a formatting task in MS Word. Being on a computer and having to do a mundane thing like that could seem ridiculous, and MS Word thinks so, too, and has a solution to that.

To format specific parts of text at different places in a document in a particular style you have to select the relevant text, give it the required font, size, special effects, alignment, etc. and then do that all over again for another bit of text. This labour can be done away with to a great extent by using Macros.

A macro is a collection of instructions, used to perform a specific task. You have to perform the task only once and record all its steps at that time in a macro and assign this macro a name. It can subsequently be "played" any number of times at other places whenever you need to perform that particular task. This repetition of tasks can be not only performed in that particular document but also in documents that you may create at a subsequent date. This saves time and, in turn, increases efficiency.

We will take up a specific example and go about the task step by step to explain the procedure. We will record and play a macro to format a text, giving it the font Arial, point size 12 and effect bold.

Select the desired text and the perform the following steps:
Recording
From the menu, select Tools > Macro > Record New Macro.
Give the macro a name (say "smallheading") and click OK.
A macro toolbar with Stop Recording and Pause Recording buttons will appear. The mouse cursor will have a small cassette like icon below it to indicate that recording is in progress. The status bar will show the word REC.
Now, change the font to Arial, size to 12 and give the bold effect.
Click the Pause Recording button if you want to perform any step and don’t want it to be recorded.
When finished, click Stop Recording.

Now, you have a set of instructions permanently stored in your hard disk for future use. A macro generates and stores a set of instructions in its own programming language behind the scene. You can work with macros without knowing that language.

Playback
This is what you do to format other parts of the text in a manner same as the above, i.e. "smallheading."
Select the relevant text.
From the menu, select Tools > Macro > Macros, or press [Alt] + F8.
Select the macro name "smallheading."
Click Run.

All aspects of formatting that you had earlier assigned to the style "smallheading" will automatically get applied to this new part of text too.

This was your first macro and as you use it you will realise how time saving it can be. You can record various tasks that you usually perform in Word. You could even type some text and record it in a macro if you need to insert it very often in the same or other documents at a later date.

Even the task of running the created macros can be reduced to shortcuts. You can run a macro by just pressing two shortcut keys instead of going to the menu bar and selecting the options from it.

Assigning shortcut keys
Click the Keyboard button while creating a macro.
You will see a text box; click the New Shortcut key. With the cursor in this box, press a combination of two keys, which you would like later to run the macro. Out of these two keys, one should be either [Alt] or the [Ctrl] key. The other key can be any numerical or letter. While entering the combination you keep the Alt/Ctrl key pressed, and then press the second key. Do not use shortcuts like [Ctrl] + C or [Ctrl] + V, which are already assigned by Windows to perform certain functions. In this example, we will give the shortcut [Ctrl] + J.
Click Assign and Close buttons.

Record the macro as described earlier.

You have now assigned a shortcut to a macro. Now to Run it you just press [Ctrl] + J.
Following a similar procedure, macros can also be used in Excel and Front Page.

— Sarabjeet Singh Kanwal

No comments: