Thread: Excel version
View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Excel version

Jim,
Seems that this may explain the behaviour:
http://groups.google.co.uk/group/mic...86e198 266b8a

However, I did see a post from Tom:
http://groups.google.co.uk/group/mic...692a3c f63aaf
that this is the normal, although that means that it not possible to
Get/Create version specific objects, which I always thought was possible.

Confused ?

NickHK

"Jim Rech" wrote in message
...
Nick-

but then noticed that I can only see the latest version


When I look at Excel.Application.11 and Excel.Application.12 (I have only
2003 and 2007 installed on this machine) I see the same CLSID for both.
That CLSID (00024500-0000-0000-C000-000000000046) points to Excel 2003 and
when I run Excel.exe from Start-Run that's what I get. So it looks like
whichever version re-registers itself last hogs all the keys.

As a practical matter I think instantiating Excel, as you said, is the way
to go. Although you apparently cannot enumerate through multiple versions
that way, at least you can get the version you will actually get when you
automate Excel, and I think that's all that matters.

Jim

"NickHK" wrote in message
...
Jim,
I was going to suggest just trying to instantiate the version, but then
noticed that I can only see the latest version, which seems strange.
I get this in the Immediate window
Excel version 10.0 is installed.
Excel version 10.0 is installed.

Private Sub CommandButton1_Click()
Dim i As Long
Dim RetVal As Variant

RetVal = GetExcelVersions()

If IsArray(RetVal) Then
For i = LBound(RetVal) To UBound(RetVal)
Debug.Print "Excel version " & RetVal(i) & " is installed."
Next
Else

End If
End Sub

Private Function GetExcelVersions() As Variant
Dim i As Long
Dim ExcelApp As Object
Dim Versions As String

On Error Resume Next
For i = 5 To 15
Set ExcelApp = CreateObject("Excel.Application." & i)
If Not ExcelApp Is Nothing Then
Versions = Versions & ExcelApp.Version & ","
ExcelApp.Quit
Set ExcelApp = Nothing
End If
Next

If Len(Versions) 0 Then
GetExcelVersions = Split(Left(Versions, Len(Versions) - 1), ",")
Else
GetExcelVersions = False
End If

End Function

NickHK

"Jim Rech" wrote in message
...
My concern with registry entries in general is are they removed if the
product is uninstalled? I think Office itself looks to the HKLM keys
such
as HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0.

--
Jim
"NickHK" wrote in message
...
| Eric,
| I have these 2 keys, as I have 2 versions of Office installed:
|
| HKEY_CLASSES_ROOT\Excel.Application.9
| HKEY_CLASSES_ROOT\Excel.Application.10
|
| NickHK
|
| "Eric" wrote in message
| ...
| Hi Gary,
|
| Anything that would work outside Excel?
|
| Eric
|
| "Gary Keramidas" <GKeramidasATmsn.com wrote in message
| ...
| Application.Version
| will return 11 for 2003, 12 for 2007
|
| environ variables i know of for your reference:
|
| ALLUSERSPROFILE
| APPDATA
| CommonProgramFiles
| COMPUTERNAME
| ComSpec
| FP_NO_HOST_CHECK
| HOMEDRIVE
| HOMEPATH
| LOGONSERVER
| NUMBER_OF_PROCESSORS
| OS
| Path
| PATHEXT
| PROCESSOR_ARCHITECTURE
| PROCESSOR_IDENTIFIER
| PROCESSOR_LEVEL
| PROCESSOR_REVISION
| ProgramFiles
| SESSIONNAME
| SystemDrive
| SystemRoot
| TEMP
| TMP
| USERDOMAIN
| USERNAME
| USERPROFILE
| WecVersionForRosebud.828
| windir
|
|
| --
|
|
| Gary
|
|
| "Eric" wrote in message
| ...
| Hello,
|
| I am trying to identify what version of Excel is install on a
system?
| Is
| there an environment variable or a Reg key that would give me
this
| information?
|
| Thank you.
|
| Eric
|
|
|
|
|
|
|
|