When to Use VBA

Although recorded macros can do just about anything in Word, it's often useful to be able to edit macros, or create new macros by writing your own VBA code. The following situations are just a few examples:

  • You have recorded a macro that works well, but now you would like to change the way it works without recording it again.

  • You want to prompt the user to input information, such as his name or a filename.

  • You want to display one of Word's dialogs so that a user can make selections from the dialog.

  • You want your macro to make logical decisions. For example, you can program a macro to function only if your current selection is in a table, or if the document is in Page Layout view.

  • You want to repeat an action many times. For example, ...

Get Special Edition Using Microsoft® Word 2000 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.