Solved

VB6- Microsoft Excel 12.0 Object Library in the References

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…

832 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