Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VBA References

Posted on 2004-10-07
11
Medium Priority
?
790 Views
Last Modified: 2008-03-17
I have been developing in VBA for Access and Excel for some time now.  I have a question about references and older versions of Office.  I just installed Office XP on my machine and have started to do some development.  If I send the database to someone with Office 2000, the reference does not downgrade to say Excel 2000.  It says the reference to Excel 10.0 library is missing.

Now the other way works fine.  If I develop in Access 2000 and have a reference to Excel 9.0 library, and someone with Office XP opens it, the VBA will automatically upgrade the reference to 10.0.

Is there any way to make sure the correct references are used, or do I have to install both Office 2000 and Office XP on my machine and add just use the older references so that it works on all machines?  Thanks.
0
Comment
Question by:ingenito
11 Comments
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 375 total points
ID: 12252433
0
 
LVL 12

Expert Comment

by:pique_tech
ID: 12252439
I have a different version of this problem with ADO references differing in version between machines and have not found a sure-fire fix.  I'll be watching to see if anyone else has.
0
 
LVL 77

Expert Comment

by:peter57r
ID: 12252481
Hello ingenito,

There is no way to force the non-Access references to downdate.

The solution to this sort of problem is to use 'late binding'.
This is a technique where you do not use any Excel reference library at all and declare the excel objects as datatype 'Object'.
Look at the CreateObject function in VBA Help.


Pete
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 12

Expert Comment

by:pique_tech
ID: 12252613
<vent>

Yuck.  "The only solution to this problem is to program in a way generally recognized as a bit shoddy."  LOL  What a brilliant Microsoft-ish solution!

</vent>
0
 

Author Comment

by:ingenito
ID: 12252933
I agree with pique_tech in that its a pretty inefficient way to go about things.  I don't want to have to write extra code and then worry about commenting everything when I take out the references.  Also, if I don't use references to begin with then the very helpful property dialog popups and such will not work.  I guess the best way would be to write a function that starts when either when the database or worksheet is opened and then check for and add references there.  Any other suggestions?
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 12253117
You can attempt to programmatically manage the references, but that could get ugly once your app gets to a machine with several dozen custom references added.  Late binding, while a little inconvenient, is the easiest solution you have to this issue.
0
 
LVL 34

Expert Comment

by:flavo
ID: 12253486
>> Also, if I don't use references to begin with then the very helpful property dialog popups and such will not work

I generally code using Early binding, then change the Dim and Set statements to use Late binding.
0
 
LVL 85
ID: 12253768
>> "The only solution to this problem is to program in a way generally recognized as a bit shoddy."  

I'd certainly not call Late Binding "shoddy" ... it's simply another programming tool.

Generally speaking you should ALWAYS program to the lowest common denominator - it your user base is using a mixture of Excel 97 and greater, then it is incumbent on you to insure that your code will work (and compile) on that platform, and you do that by either (a) doing all your development work on a machine with Excel 97 installed and referenced or (b) using late binding or (c) setting minimum requirements and enforcing them using your installation tool.

Regarding ADO references, generally speaking you should use your installer to determine file versions, and require your end user to have version xxx or greater before allowing installation to continue. Or, of course, developing on a machine with the lowest common denominator (as above) and therefore not worrying about other references. Of course, ADO (actually you're talking about MDAC here) references are notoriously difficult to deal with; mis-matched versions of any of the hundreds of files installed by MDAC can cause you no end of trouble. The solution for this is the same as above: Make sure your end user has the correct version OR make sure your dev machine has the lowest common version.
0
 
LVL 12

Expert Comment

by:pique_tech
ID: 12253846
Fair enough, I'm actually an empirical pragmatist with theoretical purist tendencies... (but not a poseur...lol)

I meant no offense.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 12263307
empirical - theoretical - in the same mind?  Probably is offensive but none taken. ;))
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question