Share this Page URL

The VBA Editor in Word > The Code Window, and Object and Procedure List Boxes - Pg. 435

Figure 18-6. IntelliSense suggesting data types The Properties sheet shows the properties of various objects and allows you to mod- ify them. You can use this window to can change the name of your VBA project by clicking on the project node in the Project Explorer, clicking the column next to (Name) , typing in a new value, and hitting Enter . The Properties sheet is especially useful for working with UserForms. The Code Window, and Object and Procedure List Boxes The Code window is used to create and modify VBA code. It has two drop-down lists, the one on the left used to select objects, and the one on the right to select procedures or events. As you type code in the code window, the editor formats it for you. Keywords are colored in blue, comments in green. When you hit Enter or move off a freshly typed statement, the editor capitalizes keywords for you. When you enter a statement with an error in it, the editor displays a message box telling you what's wrong, and colors the statement red until you fix it. As you type, you'll also notice that the editor will try to help you out. After you type the name of a defined function or subprocedure, it will show the parameters in a tool tip, bolding the one you should currently be entering. It will show a list of data types as you type your Dim statement, and a list of methods and properties after you type an object variable and a period. If you select an item from the list and hit Tab, the editor will complete the code entry for you. This feature is called IntelliSense. You can type part of a variable name or constant and have the editor take its best guess at the full name by hitting Ctrl-Space. If the editor can't complete the name for you, it will display the closest matches to the name in a list box. Figures Figure 18-6 and Figure 18-7 show some of these features in action. As I mentioned earlier, the object and procedure drop-down boxes help you code more quickly. The object drop-down box is the leftmost of the two and contains a (General) entry and objects. The (General) entry is shown when the code window's cursor is in the module's global code, where you'd type Option Explicit or your global module variables for event handlers. When the cursor is in procedure code for an object, the object is shown in the object drop-down box, and the procedure (which could be an event handler) in the procedure drop-down box. You can have Working with VBA The VBA Editor in Word | 435