Microsoft Access 2010 Bible

(Rick Simeone) #1

Part III: More-Advanced Access Techniques


792


FIGURE 22.1

Early binding by setting references is the most efficient way to perform Automation.


Note
Just because a library shows up in the list of References doesn’t mean that it can be automated from Access (or
at all).


Fortunately, Microsoft has done an outstanding job of documenting the object libraries supported
by the Microsoft Office suite, and Automation example code is available from many sources such
as books, magazines, and the Internet.

Binding your VBA object variables to objects in the


Automation interface
The process of connecting your VBA object variables to objects exposed in an application’s
Automation interface is called binding. An Automation server’s resources can’t be used until its
interface is bound to object variables in a client application.

The VBA programming language supports early and late binding:

l (^) Early binding means you write VBA code that specifies the Automation server and
directly bind object variables to the server’s interface.
l (^) Late binding means that the Automation server is not specified until runtime, and object
variables are not bound to the server’s interface until the VBA code executes on the user’s
desktop.
Early-binding an object
When you reference an object library, you’re performing early binding. Automation code executes
more quickly when early binding is used. Early binding means that, as Access starts up and the
VBA project is loaded into memory, Windows provides a connection between Access and the
Automation server. The connection between Access and the server is made before the user begins
using the features exposed by the Automation server.

Free download pdf