Using the Editor tab

Figure 7-7 shows the options that you access by clicking the Editor tab of the Options dialog box.

Editor | Editor Format | General | Docking |

pCode Settings-

V Auto Syntax Check Auto Indent f Require Variable Declaration . ,. r—

Auto List Members

W Auto Quick info

17 Auto Data Tips p Window Settings-

Drag-and-Drop Test Editing DeFault to Full Module View Procedure Separator

Figure 7-7: The Editor tab of the Options dialog box.

AUTO SYNTAX CHECK OPTION

The Auto Syntax Check setting determines whether the VBE pops up a dialog box if it discovers a syntax error while you're entering your VBA code. The dialog box tells you roughly what the problem is. If you don't choose this setting, VBE flags syntax errors by displaying them in a different color from the rest of the code, and you don't have to deal with any dialog boxes popping up on your screen.

I usually keep this setting turned off because I find the dialog boxes annoying, and I can usually figure out what's wrong with an instruction. But if you're new to VBA, you might find this assistance helpful.

REQUIRE VARIABLE DECLARATION OPTION

If the Require Variable Declaration option is set, VBE inserts the following statement at the beginning of each new VBA module that you insert:

Option Explicit

If this statement appears in your module, you must explicitly define each variable that you use. This is an excellent habit to get into although it does require some additional effort on your part. If you don't declare your variables, they will all be of the Variant data type, which is flexible but not efficient in terms of storage or speed. I discuss this in more depth in Chapter 8.

Changing the Require Variable Declaration option affects only new modules, not existing modules.

AUTO LIST MEMBERS OPTION

If the Auto List Members option is set, VBE provides some help when you're entering your VBA code by displaying a list of member items for an object. These items include methods and properties for the object that you typed.

This option is very helpful, and I always keep it turned on. Figure 7-8 shows an example of Auto List Members (which will make a lot more sense when you actually start writing VBA code). In this example, VBE is displaying a list of members for the Application object. You can just select an item from the list, thus avoiding typing it. (Hint: This also ensures that it's spelled correctly.)

| '^Book4 - Module! (Code)

H7IS

ü

1

1 (General)

[Vest

d

Sub TestO

Username=applicati[

Dn.us

End Sub

nS* UsableHeight

-d

là? UsableWidth

uff UsedObjects

eû* UserControl

là? UserLibraryPath

US' UseSystemSeparators ^

JJ

y

1

JL

m

Figure 7-8: An example of Auto List Members.

Figure 7-8: An example of Auto List Members.

AUTO QUICK INFO OPTION

If the Auto Quick Info option is set, the VBE displays information about the arguments available for functions, properties, and methods while you type. This can be very helpful, and I always leave this setting on. Figure 7-9 shows this feature in action. It's displaying the syntax for the Range property.

|^Book4 Modulel (Code)

m

|l Generali jJ J Test

-3

Sub Test[]

Set HyRange=range (|

End Sub Range(Ceflf, \CeH2[) As Range |

a

IjJ_1

Figure 7-9: An example of Auto Quick Info offering help about the Range property.

Figure 7-9: An example of Auto Quick Info offering help about the Range property.

AUTO DATA TIPS OPTION

If the Auto Data Tips option is set, VBE displays the value of the variable over which your cursor is placed when you're debugging code. When you enter the wonderful world of debugging, you'll definitely appreciate this option. I always keep this option turned on.

AUTO INDENT OPTION

The Auto Indent setting determines whether VBE automatically indents each new line of code by the same amount as the previous line. I'm a big fan of using indentations in my code, so I keep this option on. You can also specify the number of characters to indent; the default is four.

Use the Tab key to indent your code and not the space bar.Using the Tab key results in more consistent spacing. In addition, you can use Shift+Tab to unindent a line of code. These keys also work if you select more than one statement.

DRAG-AND-DROP TEXT EDITING OPTION

The Drag-and-Drop Text Editing option, when enabled, lets you copy and move text by dragging and dropping. I keep this option turned on, but I never use drag-and-drop editing. I just prefer to use keyboard shortcuts for copying and pasting.

0 0

Post a comment