appXL = CreateObject("Excel.Application")

D

Desaivres Alain

Hi

Both Excel 2003 and Excel 2007 are installed on a subset of machines
How to control the object version open when this script line is executed ?
Set appXL = CreateObject("Excel.Application")

The test on two machines shows that it is the xcel 2003 (version 11.0) that
is opened, the same one you get if you doubleclick on an .xls file while
neither Excel 2k3 nor Excel 2k7 is opened...

Does it mean there is somewhere a variable that tell to Office which Excel
to open in case several would be installed ?

Thanks for your help
Alain
 
E

Estaup

I would think the Office Library version being referenced in your code would
dictate the version of Excel being initiated.

I don't have both on one machine here, but looking at Excel projects on both
03 and 07, there are different libraries referenced.

Does the 03 version show in your references?
 
J

JP

Try this:

Dim obj1 As Object
Dim obj2 As Object

' open Excel 2003
Set obj1 = CreateObject("Excel.Application.11")

' open Excel 2007
Set obj2 = CreateObject("Excel.Application.12")

--JP
 
D

Desaivres Alain

Thanks but unfortunately both objects return 12.0 when you query for
objx.Application.version

Alain
 
D

Desaivres Alain

Thanks Steve

This could be a good solution into other circumstances but what I am doing
is a script that run at login time and that check if there would not be any
update to run for one or several xla...

In such a situation, I can run createobjects(excel.application) without
disturbing so much the launch phase of the PC but cannot open Excel, I mean
both excel 2003 and Excel 2007...

Thanks for your contribution
Regards
Alain
 
D

Desaivres Alain

Hi...

In fact I have been able to find some more info about that topic and have
already experienced new situation...

When you install to different versions of Excel on a given machine, the
Excel version that will be opened per default while double clicking on an
..xls file will be the last one that have been installed...

Same for the command line
appXL = createObject(Excel.Apllication)
appXL.Application.version will return the bversion of the last one installed

MSDN says that thereis only one Class ID for both and that the unique Class
ID has been overwritten per the second one to be opened...

More or less this says that we cannot create an Excel 11.0 object if the
second Excel installed on a given machine is Excel 12.0... My purpose being
to check which xla need to be installed, I can simply not use the addins
collection to realize that or at least only on one of both versions...

My unique other possibility is to open each excel through a shell command
then to realize a getobject but such a solution is not really serious inside
a script launch at login time...

Regards
Alain
 

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