Solved

VB6- Microsoft Excel 12.0 Object Library in the References

Posted on 2013-06-02
4
2,503 Views
Last Modified: 2013-06-02
Hello all

I would like to know if there is a way to auto select the good Microsoft Excel Object Library in the macro itself  when the project is opened instead of manually select it in the reference tab? That way, if i use different Microsoft office version, my project would always work.

Microsoft Excel 10.0 Object Library
Microsoft Excel 11.0 Object Library
Microsoft Excel 12.0 Object Library
Microsoft Excel 13.0 Object Library

Thanks again
0
Comment
Question by:Wilder1626
  • 2
  • 2
4 Comments
 
LVL 45

Expert Comment

by:aikimark
ID: 39214539
You can use late binding, which uses a CreateObject() function to instantiate your Excel object.  In many cases, you can use a generic form of the object in the string parameter, such as:
Set oXL = CreateObject("Excel.Application")

Open in new window

This will use the default application version on your system, which is most likely the most recent version installed.  However, you can supply version information in the CreateObject() parameter to force a particular version of Excel to be used.  My preference is to release production versions of code with late binding, since different versions will cause early binding (reference) failures in mixed-version environments.

What determines which version you might want to use?
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 39214551
What determines which version i might use is that some of our PC are still not updated with Microsoft Office suite 2010. Some are still with Office 2007.

I was trying to see if i can have 1 compilation that would match both. But one thing is for sure, on the PC, there is only one of the version installed, 2007 or 2010
0
 
LVL 45

Accepted Solution

by:
aikimark earned 500 total points
ID: 39214560
use the generic version of the string parameter.
0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 39215073
Thanks again for your help
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

910 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

21 Experts available now in Live!

Get 1:1 Help Now