There are (at least) a couple of ways to install a macro . I will talk you through what is probably the most straightforward method later in this post, but first let us look at what a macro looks like inside Word’s Visual Basic editor.
What do macros look like
This is what the SmallCaps macro that we recorded in this post looks like in the Visual Basic editor:
All macros have the same basic structure:
You can see that it has the same structure as the SmallCaps macro, but there are fewer instructions in the body of the macro.
How to install a macro
First, go to View Macros in the Macros section of the View tab. (See the first part of this post if you’re not sure). When you click on View Macros you get a pop-up box which looks like this:
Type the name of the macro that you want to install into the top box (underneath Macro name:). I am calling my new macro TestMacro. Remember: macros are a throw-back to the old days of file naming systems so you can’t use spaces!
When you have typed the name in, click on ‘Create’. This will bring up Word’s Visual Basic editor (which is what we were looking at earlier). Clicking on 'Create' for my new macro, TestMacro, gives me:
You need to copy the body of the macro you are installing from the source document (this will probably be a web page or a Word doc) and paste it below the green quote marks and above End Sub (the cursor should automatically be in the correct place).
For my PatientsWith macro, the part that I need to copy and paste is:
My new macro – called TestMacro – will then look like this:
It’s important that you are careful to paste your text exactly where it needs to go. You will find that the Visual Basic editor automatically creates lines between each macro in your list of macros. Be careful not to delete these lines.
You then need to save your macro in the Visual Basic editor, using the Save icon at the top left-hand side.
Then, close the editor (via the File menu or the cross on the top right-hand side. When you open your list of macros, it should now contain your new macro:
Type a description of what your macro does in the 'Description:' box at the bottom.
Enjoy your new macro!
Andrea at Yours Truleigh Editing