Microsoft Office Tutorials and References
In Depth Information
Customizing the VBE Environment
You could have entered this procedure directly into a VBA module. To do so, you would have to
know which objects, properties, and methods to use. Obviously, recording the macro is much
faster, and this example has a built-in bonus: You also learned that the PageSetup object has an
Orientation property.
A point that I make clear throughout this topic is that recording your actions is perhaps
pic
the best way to learn VBA. When in doubt, try recording. Although the result may not
be exactly what you want, chances are that it will steer you in the right direction. You
can use the Help system to check out the objects, properties, and methods that appear
in the recorded code.
I discuss the macro recorder in more detail later in this chapter. See the section “The
Macro Recorder.”
Copying VBA code
So far, I’ve covered typing code directly into a module and recording your actions to generate
VBA code. The final method of getting code into a VBA module is to copy it from another
module. For example, you may have written a procedure for one project that would also be useful in
your current project. Rather than re-enter the code, you can simply open the workbook, activate
the module, and use the normal Clipboard copy-and-paste procedures to copy it into your
current VBA module. After you’ve finished pasting, you can modify the code as necessary.
And don’t forget about the Internet. You’ll find thousands of VBA code examples at Web sites,
forums, and blogs. It’s a simple matter to copy code from a browser and paste it into a VBA module.
As I note previously in this chapter, you can also import an entire module that has been
exported.
Customizing the VBE Environment
If you’re serious about becoming an Excel programmer, you’ll be spending a lot of time with the
VBE window. To help make things as comfortable as possible, the VBE provides quite a few
customization options.
When the VBE is active, choose Tools Options. You see a dialog box with four tabs: Editor,
Editor Format, General, and Docking. I discuss some of the most useful options on these tabs in
the sections that follow. By the way, don’t confuse this Options dialog box with the Excel Options
dialog box, which you bring up by choosing Office Excel Options in Excel.
 
Search JabSto ::




Custom Search