VBA Code for Reference file (1 Viewer)

Local time
Today, 08:09
Joined
Oct 7, 2016
Messages
43
I am using my Ms Access 2003 database file is two different Ms Office Version's. I am using Excel file in it

But Whenever I update the database and keep it is different locations, On Opening it is gives us an error "Your My.mdb database or project contains a missing or broken reference to the file" I need to change the reference file path of Ms-Excel.exe in both locations

In Access :2003
VBA-Environment--> Tools --> Reference --> Microsoft Excel 12.0 Object Library

In Access :2007
VBA-Environment--> Tools --> Reference --> Microsoft Excel 16.0 Object Library

Kindly suggest us how to write a VBA Code so that both reference file detail is mention to avoid the above error.
 

isladogs

MVP / VIP
Local time
Today, 15:09
Joined
Jan 14, 2017
Messages
18,186
If you use the 2003 Excel reference, it will work in 2007 or later. However you cannot then reopen it in 2003.
A workaround is to have two different copies of the app for each Access version.
However, a better solution is to use late binding for all your Excel related code. By doing that you can remove the Excel reference so the app will work in both versions of Access
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:09
Joined
Oct 29, 2018
Messages
21,359
Kindly suggest us how to write a VBA Code so that both reference file detail is mention to avoid the above error.
Hi. I agree, late binding would solve your problem. But to suggest how to write your VBA code using late binding, we'll have to see your Excel code, so we can tell you how to convert it into late binding.
 

Users who are viewing this thread

Top Bottom