Solved

VBA References

Posted on 2004-10-07
11
779 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 125 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 50

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 84
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

747 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now