General discussion


VBA reference Excel 2003 on Excel 2000

By bud.luskus ·
We are writing a VBA macro on a system loaded with Office 2003 that accesses an Excel spreadsheet.

When we take this macro to a machine that is running an earlier version of Excel we receive an error that states that it cannot find the Excel Object Library.

Tracing the error shows that versions of Excel prior to Office 2003 access an object library with the extension .olb. The reference for Excel 2003 is to excel.exe. Is there a way to make this VBA macro 'backward compatible' at runtime?

The program that is running the VBA macro is Autodesk Actrix Technical 2000.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by gerald.bowen In reply to VBA reference Excel 2003 ...

I have seen a similar problem when moving Excel macros from one machine to others. Some of the problems were caused by different .dll versions on the various machines.
The problem can often be fixed/bypassed by using "Option Explicit" in the Declarations section of the macro and declare all variables before using them.

Collapse -

by messegger In reply to VBA reference Excel 2003 ...

If the problem is caused by going from a newer version of Excel to an older version, the solution might be to do the development on the oldest version.
I believe if you write your code in the oldest version 2002 and open it in 2003 it will update the references for you.
However,you could use late-binding. Instead of relying on a specific version, you create a "version-independent" object that doesn't use references.

It's very nice to use early binding when developing. You get all the intellisense help (when you set the reference and declare the variables nicely). But before you distribute it to users (who may be using different versions), it's usually a good idea to use latebinding (and change those object variable declarations to the generic "As Object".)

Here are some more extensive references on binding:
Use late binding - don't have a reference to excel.;EN-US;244167
INFO: Writing Automation Clients for Multiple Office Versions;en-us;245115
INFO: Using Early Binding and Late Binding in Automation;en-us;247579
INFO: Use DISPID Binding to Automate Office Applications Whenever Possible

Related Discussions

Related Forums