[AccessD] Missing references

JWColby jwcolby at colbyconsulting.com
Thu Feb 15 15:56:40 CST 2007


BTW, you can use BOTH early binding and late binding by wrapping TWO sets of
dim statements in #if statements:

#Const EARLYBINDING = True

#If EARLYBINDING = -1 Then
Private mxlApp As Excel.Application
Private mXLWB As Workbook
Private mXLWS As Worksheet
#Else
Private mxlApp As Object
Private mXLWB As Object
Private mXLWS As Object
#End If

Now you can simply set EARLYBINDING to TRUE (-1) and the compiler will dim
the objects at compile time.

Set EARLYBINDING to 0 and the compiler will dim the objects at run time.  

I do this so that I can use early binding during development, and then just
"throw a switch" to use late binding for runtime on the actual user's PC.
Of course you have to do that everywhere you want to bind such objects,
inside of functions that dim local objects, in the header for global objects
etc.

Once it is set up though it works very sweet.

And Oh By The Way, there is a GLOBAL (to every module in the library) way to
do this:

In the VB Editor, click Tools / MyContainer Properties (the bottom menu
item)
In the General tab there is a "Conditional Compilation Arguments" where you
could define your EarlyBinding constant.  

Doing it there causes ALL MODULES that use that constant to switch from
early binding to late binding and back.

Very handy!!!

John W. Colby
Colby Consulting
www.ColbyConsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Bryan Carbonnell
Sent: Thursday, February 15, 2007 4:38 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Missing references

On 2/15/07, Mark A Matte <markamatte at hotmail.com> wrote:

> Since I'm not versed in Binding(Late or Early) ...I've looked at MS 
> knowledge base...and most of what I found was problems and fixes.
>
> Any suggestions for 'crash course READING' in bindings?

Here's a quick description that I lifted from an article I wrote
http://www.databaseadvisors.com/newsletters/newsletter072002/0207wordautomat
ionlpt1.asp


Early Binding Versus Late Binding

First you need to decide whether to use Early Binding or Late Binding.
Early Binding allows you to dimension variables by their specific data type.
For example, the following declarations refer to the Word Application and
Document objects rather than declaring both as generic
objects:

Dim objWord as Word.Application
Dim doc as Word.Document

Early Binding also enables a few built-in Intelli-sense features: Auto
Complete, Auto List Members, and Auto Quick Info. In addition, using early
binding allows you to view Word's object model in the Object Browser.

The downside to Early Binding is that you have to set a reference to a
specific version of Word. Sometimes Access is smart enough to change the
reference to the specific version of Word that is installed on the PC you
are deploying your application; often it isn't, and you could end up with
problems relating to the references.

If you decide to use Late Binding, you will have to dimension all of your
variables as Objects as follows:

Dim objWord as Object
Dim doc as Object

Consequently, you cannot access any of your variables until you set them to
a specific object as shown below:

Set objWord = CreateObject("Word.Application") Set doc =
objWord.Documents.Open("C:\Path\To\file.doc")

In addition, the Intelli-sense features, Auto Complete, Auto List Members,
Auto Quick Info and disables viewing of Word's object model in the Object
Browser. However, Late Binding doesn't require that you set a reference to
any Word Object Library, which can be advantageous if you are deploying
run-time versions of your application to mixed OS/Office Version platforms.

Instead of choosing one or the other, we suggest you compromise and use
both. During the development phase use Early Binding. Once you release the
application, remove all specific references and change each to Object-the
best of both worlds!

Now that the binding issue is resolved, let's roll up our sleeves and dive
into writing some code.



--
Bryan Carbonnell - carbonnb at gmail.com
Life's journey is not to arrive at the grave safely in a well preserved
body, but rather to skid in sideways, totally worn out, shouting "What a
great ride!"
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list