Office 2010 - Word

Lesson 65: Macros

65/66 Lessons 

Macro:

A macro is a series of automated actions, which accomplishes one or more tasks with the simple click of a button.
A macro records the actions you perform on your keyboard and stores it as a Visual Basic Module.
When we want to repeat all these steps, later, we just need to click one button.
For example, suppose you have the name, address, and fax and phone number on every page of your document.
It would not be very useful to enter all these again and again, for each page, so we enter this information once, and then save it as a macro.

To create a macro, select the “View” tab in the ribbon, click the “Macro” button, and select “Record Macro” from the drop-down menu.
les65_image001_en
This opens the “Record Macro” dialog box.
In the upper section, we give our macro a suitable name, for eg. “Name Address”. The name of a macro cannot contain spaces, otherwise it will not work. In the “Description” text box, you may have to optionally enter a description.
In the next part of the dialog, we must decide how we want to run the macro later. If we want to assign a macro to a button in the “Quick Access toolbar”, then click the “Button” button and, if you want to run your macro when you press a key on your keyboard click the “Keyboard” button.

In this example, I click “Button”.
This opens the “Word Options” dialog box, where the “Quick Access Toolbar” tab is selected.
I select the button in the left pane, and click the “Add >>” button in the middle of the dialog box.
Alternatively you can set the icon and name of the button by clicking the “Modify” button in the dialog box.
les65_image002_en
les65_image003_en
This opens a second dialog box, where we can select a symbol for our button and, also a display name.
Click OK when you’re done.

Then click OK to close the “Word Options” dialog box.
Our mouse pointer now changes to an arrow with a cassette recorder.

Every action we perform is included in our macro.
When you have finished recording the macro, click the “Macro” in the ribbon, again, and select “Pause/Stop Recording” from the drop-down menu.
les65_image005_en

Running a Macro:

The button with the macro we just created is now added to our “Quick Access toolbar”.
les65_image006_en

Whenever we click this, the macro will be executed.

Changing a Macro:

Those of you who know a bit of Visual Basic, can change the macro.
Those of you for whom all this is new, had better delete and recreate your macro.
To modify a macro, click the “Macro” button in the ribbon, and select “View Macro”.
This opens the “Macros” dialog box.
The dialog box that appears displays all the macros that we have already created.
To delete a macro, select it in the left pane, and click the “Delete” button.
Those who want to modify a macro, can select the macro, and click the “Edit” button.
This opens the ‘Microsoft Visual Basic for Applications”, VBA in brief:
les65_image007_en
If your email address has been chaged, you can change it here.
For those of us who are more advanced, you have two lines in the code:
Application.Resize Width: = 566, Height: = 483
Application.Move Left: = 391, Top: = 56
These are quite obvious, so they can be removed.
Or maybe not. It is entirely your choice.
But, if you know nothing of VBA, you had better not change anything.
Close the “Microsoft Visual Basic” window by clicking on the red X icon at top right of the window.

When I have some time and when there is demand, I will probably write a VBA course.

Awesome!
You've completed Lesson 65
START NEXT LESSON