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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3219
  • Last Modified:

VB6- Microsoft Excel 12.0 Object Library in the References

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
Wilder1626
Asked:
Wilder1626
  • 2
  • 2
1 Solution
 
aikimarkCommented:
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
 
Wilder1626Author Commented:
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
 
aikimarkCommented:
use the generic version of the string parameter.
0
 
Wilder1626Author Commented:
Thanks again for your help
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now