Excel.Application Instantiating Different Versions

T

Tom Antola

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top