Page 67 - Microsoft Office Excel 2003 Programming Inside Out
P. 67

Chapter 4


                    VBA Programming Starter Kit€




                             Introducing the Visual Basic Editor. . . . . .41   Creating Dynamic Arrays . . . . . . . . . . . .66
                             Managing Code Windows . . . . . . . . . . . . .53   Writing to the Screen and
                             Developing Projects with the           Accepting Input  . . . . . . . . . . . . . . . . . . .67
                             Project Explorer. . . . . . . . . . . . . . . . . . . . .55   Defining Object Variables. . . . . . . . . . . .72
                             Declaring Variables, Constants, and    Creating Custom Data Types . . . . . . . . .72
                             Data Types  . . . . . . . . . . . . . . . . . . . . . . . .57   Controlling Program Flow. . . . . . . . . . . .73
                             Assigning Values to Variables . . . . . . . . . .64   Error Handling  . . . . . . . . . . . . . . . . . . . .82
                             Working with Arrays . . . . . . . . . . . . . . . . .64



                    Introducing the Visual Basic Editor

                             The Visual Basic Editor is a powerful tool that lets you extend the power and versatility of
                             macros beyond anything that can be done through recording alone. So that you can fully
                             understand how to use the Visual Basic Editor, this chapter examines all facets of the
                             Visual Basic Editor: what the various components are, what they do, and how to use them.
                             With that purpose stated, it’s time to examine the Visual Basic for Applications language,
                             which is used to program all macros.
                             If you have never worked with the Visual Basic Editor before, you might find it more
                             convenient to work through this chapter from start to finish. If you’ve worked with the
                             Visual Basic Editor before, jumping to specific sections will allow you to quickly find the
                             information you are seeking.


                    Opening the Visual Basic Editor
                             As with most Microsoft Windows–based applications, there are several methods for opening
                             the Visual Basic Editor. You can select Tools, Macro, Visual Basic Editor from the menu bar or
                             press Alt+F11. If there is a specific macro that you want to edit or view, you can select Tools,
                             Macro, Macros to bring up the Macro dialog box. From there, you can highlight the macro
                             you want to work with and select the Edit button. You can also open the Macro dialog box by
                             pressing Alt+F8.

                    Recognizing Parts of the Visual Basic Editor

                             When you open the Visual Basic Editor directly, you use the Project Explorer window to
                             select the macro you want to work on. The Project Explorer presents all projects (groupings of
                             code) and the macros they contain in a tree view that works the same as the tree view in



                                                                                                        41
                                                                                        Part 2:  Visual Basic for Applications
   62   63   64   65   66   67   68   69   70   71   72