ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel.Application Instantiating Different Versions (https://www.excelbanter.com/excel-programming/276640-excel-application-instantiating-different-versions.html)

Tom Antola

Excel.Application Instantiating Different Versions
 
All,

I have a computer that has multiple versions of MS Excel. How can I
instantiate and automate a specific version?

I've tried several attempts using the late bound functions, CreateObject and
GetObject, but no matter what, I always instantiate the current version.
Here is a sample of what I tried

Dim obj as Object
Set obj = CreateObject("Excel.Application.10")
MsgBox obj.Version
Set obj = Nothing

This code always instantiate the current version in the registry. I suppose
I could modify the current version in the registry before instantiating
Excel but I would rather not have to do that. I would much rather have
something that reads like this pseudo code:

Dim obj as Object
If (VersionNeeded = 8) Then
Set obj = CreateObject("Excel.Application.8")
ElseIf (VersionNeeded = 9) Then
Set obj = CreateObject("Excel.Application.9")
ElseIf (VersionNeeded = 10) Then
Set obj = CreateObject("Excel.Application.10")
EndIf
MsgBox obj.Version
Set obj = Nothing

Can anyone help me?

Thank you,
Tom




All times are GMT +1. The time now is 11:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com