Chapter 2. Writing Your Own Macros

     

In this chapter

  • Understanding the advantages of writing your own macros

  • Getting to know the Visual Basic Editor

  • The basic steps required to write a macro

  • Learning how to craft your very own user -defined functions

  • Creating and using procedures

  • Understanding and working with VBA modules

Letting VBA do all the work by recording your macros is an easy way to automate tasks , and it's a technique you'll use often. However, to get the most out of VBA, you need to do some full-fledged programming, which means writing your own macros, either from scratch or by using a recorded macro as a starting point. Here are just a few of the advantages you gain by doing this:

  • If you make a mistake while recording a macro, particularly one that requires a large number of steps, you can edit the macro to fix the mistake rather than re-recording the whole thing from scratch.

  • You get full control over each macro, which means you ensure that your macros do exactly what you need them to do.

  • You can take advantage of the hidden power of VBA to manipulate the Office programs and to perform some impressive programming feats that are simply not available via the recording process.

To help you realize these advantages and many more, this chapter introduces you to the basics of writing simple procedures and functions, as well as how to get around in the Visual Basic Editor, which is the tool that VBA provides for writing macros by hand. This will set the stage for the next few chapters when I take a closer look at the specifics of the VBA language.



Absolute Beginner's Guide to VBA
Absolute Beginners Guide to VBA
ISBN: 0789730766
EAN: 2147483647
Year: 2003
Pages: 146

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net