Solved

VB6- Microsoft Excel 12.0 Object Library in the References

Posted on 2013-06-02
4
2,455 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

744 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

11 Experts available now in Live!

Get 1:1 Help Now