4.1. Setting Up The Visual Basic Editor For Creating The Procedures

You'll find it easiest to follow the instructions in the following procedures if you have the Visual Basic Editor set up in a default configuration (like the layout you see the first time you display the Visual Basic Editor from a VBA host).

For good practice, you should also allow the Visual Basic Editor to enforce explicit variable declaration. The following steps describe how to set up the Visual Basic Editor. Each of the procedures tells you when to make sure the Visual Basic Editor is set up correctly.

  1. If the Project Explorer isn't displayed, choose View Project Explorer or press Ctrl+R to display it.

  2. If the Properties window isn't displayed, choose View Properties Window or press the F4 key to display it.

  3. Unless you really prefer things otherwise, dock the Project Explorer in its conventional position at the upper-left corner of the main Visual Basic Editor area. Dock the Properties window below the Project Explorer, again in its default position. (To change docking, choose Tools Options, click the Docking tab, and work on the Docking page of the Options dialog box.) To dock an undocked (floating) window, double-click its title bar.

  4. Close any Code windows or user form windows that are open.

  5. Set the Visual Basic Editor up to require variables to be declared explicitly, so that you must declare each variable formally before you use it. Choose Tools Options to display the Options dialog box, select the Require Variable Declaration check box on the Editor page, and then click the OK button. This setting makes the Visual Basic Editor automatically enter an Option Explicit statement for all modules and user forms you create from now on. And that statement causes the editor to check during runtime for any implicitly declared variables and require that you declare them explicitly, like this:

    Dim txtName As String

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.191.30