Edit the macro code

If you open a macro in the Visual Basic Editor you can do all the following:

  • Make corrections
  • Remove unnecessary steps
  • Rename or copy individual macros
  • Add instructions that you cannot record in Word.
IDevice Icon Video

Watch the following video to see a demonstration of how to view and edit macro code:

Flash video: Edit macro code


Multi-select
Which of the following statements are true? (Select all that are true.)
The name of the macro is shown after the word End Sub.
The executing code for the macro is written between the lines Sub and End Sub.
Any text which is preceded by an apostrophe is executable code.
You should only add new code between the lines Sub and End Sub.



IDevice Question Icon Multi-choice
To display Visual Basic Help:
       
Press F1.
Place the cursor in the middle of a word and press F1.
Click the Microsoft Word icon on the standard toolbar.

A message box is:
       
A box where the user types information.
A box where you can create a variable name.
A box that gives information to the user.

To create a message box:
       
Type InputBox followed by the message in brackets.
Type MsgBox followed by the message in inverted commas.
Type vbExclamation

IDevice Icon Activity 6: Edit the Name macro
  1. From the Macros dialog box select the Name macro.
  2. Click the Edit button to view the macro code.
  3. Change the font name.
  4. Change the size of the font.
  5. Change the colour of the font.
  6. Run the macro again.

IDevice Icon Activity 7: Add a message box
  1. From the Macros dialog box select the Name macro.
  2. Click the Edit button to view the macro code.
  3. Create a blank line before the End Sub line in the code and type MsgBox “Great Name”, vbExclamation
  4. Return to Word by clicking on the Word icon on the Standard toolbar.
  5. Run the macro again.

Use the menu on the left to navigate your way to the next page.