Article ID: 179027
Article Last Modified on 2/12/2007
APPLIES TO
- Microsoft Office XP Developer Edition
- Microsoft Office 2000 Developer Edition
- Microsoft Visual Basic 5.0 Learning Edition
- Microsoft Visual Basic 6.0 Learning Edition
- Microsoft Visual Basic 5.0 Professional Edition
- Microsoft Visual Basic 6.0 Professional Edition
- Microsoft Visual Basic 5.0 Enterprise Edition
- Microsoft Visual Basic 6.0 Enterprise Edition
- Microsoft Visual Basic 4.0 Standard Edition
- Microsoft Visual Basic 4.0 Professional Edition
- Microsoft Visual Basic 4.0 Professional Edition
- Microsoft Visual Basic 4.0 16-bit Enterprise Edition
- Microsoft Visual Basic 4.0 32-Bit Enterprise Edition
This article was previously published under Q179027
SYMPTOMS
The following error message displays when you attempt to use a predefined
constant for an automation server:
"Compile Error:
Variable Not Defined"
For example, you may receive this error when you try to use the constant
xlR1C1 from the Microsoft Excel Object Library.
CAUSE
You are using late binding on an ActiveX component.
RESOLUTION
You can use early binding by referencing the object library for the
automation server in your project. Click References on the Project menu to
select the object library.
or-
If you want to use late binding, declare your own constant and assign it to
the numeric value of the predefined constant. For example, the constant
xlR1C1 is equivalent to -4150. Therefore, you could add the following to
your project.
STATUS
This behavior is by design.
MORE INFORMATION
Late binding occurs when you declare a variable As Object, As Form, As
Control, or As Variant and Visual Basic cannot determine at compile time
what sort of object reference the variable will contain. Therefore, Visual
Basic must use late binding to determine at run time whether the actual
object has the properties and methods you call using the variable.
Early binding occurs when you make a reference to the object library at
design time. Visual Basic then knows what object library contains the
properties and methods when you make your variable call. Early binding also
provides some performance gains.
REFERENCES
"How Binding Affects ActiveX Component Performance" in the Visual Basic
Component Tools Guide, version 5.0.
Keywords: kberrmsg kbinterop kbautomation kbprb KB179027