Microsoft Office Tutorials and References
In Depth Information
Figure 4-4. A syntax error message
that Microsoft refers to this type of error as a compile error in the dialog box and perhaps we
should as well. However, it seems more descriptive to call it a design-time error or just a syntax
Figure 4-4. A syntax error message
4.5.2 Compile-Time Errors
Before a program can be executed, it must be compiled , or translated into a language that the
computer can understand. The compilation process occurs automatically when we request that a
program be executed. We can also specifically request compilation by choosing the Compile
Project item under the Debug menu.
If Excel encounters an error while compiling code, it displays a compile error message. For
example, the code in Figure 4-5 contains a compile-time error. In particular, the first line:
Dim wb as Workbook
defines a variable of type Workbook to represent an Excel workbook. (We will go into all of this
in Chapter 17 , so don't worry about the details now.) However, the second line:
Set wb = ActiveWorkbook.Name
attempts to assign the variable wb not to the active workbook, which would be legal, but to the
name of the active workbook. This error is not caught during design time because it is not a syntax
error. It is only at compile time, when Excel considers the statement in the context of the first
statement, that the error becomes evident.
Figure 4-5. A compilation error message
4.5.3 Run-Time Errors
Search JabSto ::

Custom Search