View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Howard Kaikow Howard Kaikow is offline
external usenet poster
 
Posts: 269
Default Excel registry key

My first post was:

"Does the following key exist in the Windows XP and Windows Vista registries
for an installed Excel?
The example is for Excel 2003 (version 11).

'[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared
Tools\MSInfo\Categories\Applications11\Excel11]"

Second post was:

"The usual method for displaying a string that identifies the version of a
program, in this case Excel, is to start the app, get the version and then
use a Select Case or If to determine which string to display.

A better, or more general, way would be to use the API to first see whether
the app is installed.
If installed, determine the version specific progid, then get the "title":
of the prog from the registry BEFORE opening the program.

This eliminates the need to hard code titles within programs, and, as long
as MSFT does't change things, eliminates the need to change the program, for
this purpose, by hard coding titles of future versions.

Being masochistic, I looked thru the registry and found the key I
referenced.
If the same key is available in Win 2000, XP and Vista, the hard coding of
titles is not necessary,

Of course, I have tested this only for Excel 2003, not yet for Excel 97,
2000, or 2002.
I expect to do this next week."

Currently, the following interim code works ( I left out obvious functions):

sProgIDVersion = GetProgIDVersion(sProgID)
sProgVersion = TrimNull(Mid$(sProgIDVersion, Len(sProgID) + 2))
On Error GoTo 0
' Debug.Print sProgID, sProgIDVersion, sProgVersion
' Debug.Print GetRegistryString(HKEY_CLASSES_ROOT, sProgIDVersion)
'8:Microsoft Excel 97 Application
'9:Microsoft Excel Application
'10:Microsoft Excel Application
'11:Microsoft Office Excel Application
If Len(sProgVersion) < 0 Then
Select Case CLng(sProgVersion)
Case Is < 8
MsgBox "This program requires the installed version of
Microsoft Excel to be at least Microsoft Excel 97.", _
vbCritical + vbOKOnly, sFormTitle
Unload Me
Exit Sub
Case 8
'[HKEY_CLASSES_ROOT\Excel.Application.8]
sExcel = GetRegistryString(HKEY_CLASSES_ROOT,
sProgIDVersion)
Case 9
'[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared
Tools\MSInfo\Categories\Applications11\Excel11]
sExcel = GetRegistryString(HKEY_LOCAL_MACHINE, _
"SOFTWARE\Microsoft\Shared
Tools\MSInfo\Categories\Applications" _
& sCharBackSlash & "Excel")
Case Else '10,11,???
'[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared
Tools\MSInfo\Categories\Applications11\Excel11]
sExcel = GetRegistryString(HKEY_LOCAL_MACHINE, _
"SOFTWARE\Microsoft\Shared
Tools\MSInfo\Categories\Applications" _
& sProgVersion & sCharBackSlash & "Excel" &
sProgVersion)
End Select
End If
' Debug.Print sExcel
'8:Microsoft Excel 97 Application
'9:Microsoft Excel 2000
'10:Microsoft Excel 2002
'11:Microsoft Excel 2003
If Len(sExcel) = 0 Then
sExcel = "Microsoft Excel version " & sProgVersion
End If