- slide 1 of 6
I bet there are times when you have conducted the same task repeatedly in your Word document. In my opinion, if you do the same thing over five times, it is worth considering constructing a macro that will do the job with a single click.
- slide 2 of 6
What is VBA?
Visual Basic for Applications – or VBA as it is called – is a computer language intended to help Office users to improve their application performance. The language is a powerful tool, yet it was designed by Microsoft to be intuitive, intended to be used by people with little programming experience. The commands have comprehensive names and the properties/methods concept is also easily understandable, which is why it is relatively easy to start using VBA. Of course, serious programming is also possible, providing almost endless opportunities for more advanced users/programmers.
- slide 3 of 6
The basic VBA is the same for all Ms Office applications (Excel, Word, Outlook, etc.). However, each program has unique objects. In Excel, we work with worksheets and cells; in Word, we work with documents. It must be noted that by default every macro is stored in a document template – a .dot file (usually normal.dot) – that is connected to the .doc itself. However, the macro can be “copied” into the document and stored within the Word file via Organizer Tool.
- slide 4 of 6
Where to Begin
The easiest way to start working with VBA is to record a macro. This can be done in Word 2003 by accessing Main Menu -> Tools -> Macro and hitting the “Record new macro” button. In Word 2007, it is done by accessing the Developer tab in the main menu and hitting the “Record macro” button.
You will then be taken to a screen asking you to name the macro and decide where it should be sorted (template or current document). You can also assign a shortcut to your macro, so it will be executed each time by hitting certain key combination.
- slide 5 of 6
Record and Edit
Once the recording is done (the process will be discussed in the following article), you can use the macro “as is” by pressing the predefined keyboard shortcut (or by using Menu -> Tools -> Macro -> Macros in Word 2003 and Developer tab -> Macros in Word 2007). You can change it to suit your needs using the VB editor. It is always wise to start macro construction with recording. This way you do not have to look for commands, as Word does it for you! All you need to do is to modify them to your specific requirements.
- slide 6 of 6
Ms Word VBA is a powerful tool designed to be used by programmers as well as by users without any programming experience. It is relatively easy to master (to a certain level) as the language is intuitive. Recording macros and editing them is almost a “must” ability for an advanced Word user.