ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   appXL = CreateObject("Excel.Application") (https://www.excelbanter.com/excel-programming/440765-appxl-%3D-createobject-excel-application.html)

Desaivres Alain

appXL = CreateObject("Excel.Application")
 
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



Estaup

appXL = CreateObject("Excel.Application")
 
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?


"Desaivres Alain" wrote:

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



Steve Yandl[_3_]

appXL = CreateObject("Excel.Application")
 
There are a number of indicators in the registry where the current version
is identified. I suspect the registry value for the key
HKEY_CLASSES_ROOT\Excel.Application\CurVer is the one in play here.

I don't have a system to test this on but I think you might be able to
launch your preferred version using 'Shell' and pointing to the appropriate
exe file and then grab your application object using 'GetObject' instead of
'CreateObject'.


Steve Yandl


"Desaivres Alain" wrote in
message ...
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



JP[_4_]

appXL = CreateObject("Excel.Application")
 
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


On Mar 18, 9:27*am, Desaivres Alain
wrote:
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



Desaivres Alain

appXL = CreateObject("Excel.Application")
 
Thanks but unfortunately both objects return 12.0 when you query for
objx.Application.version

Alain

Desaivres Alain

appXL = CreateObject("Excel.Application")
 
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


Desaivres Alain

appXL = CreateObject("Excel.Application")
 
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

Desaivres Alain

appXL = CreateObject("Excel.Application")
 
You can visit http://support.microsoft.com/kb/214388
in case interested in the topic

Regards
Alain


All times are GMT +1. The time now is 11:50 PM.

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