Changing a DLL reference programmatically?

D

Dennis

In Access 2003, I have a need to programmatically set a reference to the
Excel Object Library. This reference actually points to "EXCEL.EXE". Because
of that, I need to change the reference when the Access application starts
up, depending upon which version of Office is installed. (As you all know,
the file path for the various components that make up Office change with each
release.) Basically I want to write some VBA code that determines what
version of Office is in use, then sets the program reference depending on
that value.

Any thoughts on how I could do this, or an alternative methodology
altogether, would sure be appreciated!
 
T

Tony Toews [MVP]

Dennis said:
In Access 2003, I have a need to programmatically set a reference to the
Excel Object Library. This reference actually points to "EXCEL.EXE". Because
of that, I need to change the reference when the Access application starts
up, depending upon which version of Office is installed. (As you all know,
the file path for the various components that make up Office change with each
release.) Basically I want to write some VBA code that determines what
version of Office is in use, then sets the program reference depending on
that value.

1) You can't change references in an MDE.

2) You are better to use late binding so it doesn't matter what
version of Excel or even if Excel is installed on the client system.

Late binding means you can safely remove the reference and only have
an error when the app executes lines of code in question. Rather than
erroring out while starting up the app and not allowing the users in
the app at all. Or when hitting a mid, left or trim function call.

This also is very useful when you don't know version of the external
application will reside on the target system. Or if your organization
is in the middle of moving from one version to another.

For more information including additional text and some detailed links
see the "Late Binding in Microsoft Access" page at
http://www.granite.ab.ca/access/latebinding.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top