View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default Dealing with old higher versions in registry

Still trying to get a completely foolproof method to install a .xla add-in.

My currrent method goes like this in pseudo code:

Get the path to the current Excel version from:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\App
Paths\Excel.exe

From this Excel.exe file get the file version number. This could be
something like 10.0.2.26

From this get the registry Office version number, so something like 10.0,
with some string manipulation.

Remove any entries under the reg keys for that particular Office version:
HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\E xcel\Add-in Manager
HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\E xcel\Options

Then run a simple VB6 exe like this:

Sub Main()

Dim oXL As Object
Dim oAddin As Object
Dim strLocalDrive As String

Set oXL = CreateObject("Excel.Application")

strLocalDrive = Left$(oXL.Path, 1)

oXL.Workbooks.Add
Set oAddin = _
oXL.AddIns.Add(strLocalDrive & _
"\RBSSynergyReporting\Program\SynergyReportingLoad er.xla",
True)
oAddin.Installed = True

oXL.Quit
Set oAddin = Nothing
Set oXL = Nothing

End Sub


I thought that this would always work, but there is a problem when say the
current Excel version is 9
and there is a reg key like for example:
HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\E xcel\Options

The VB6 exe then will give an error:
Run-time error '-2147417851 (80010105)':
Method '~' of object '~' failed

And in fact the add-in gets installed in the registry under the higher
Office version key.
Deleting this spurious higher Office key will solve it but Excel will behave
strange on the first startup after this.


What would be the best way to avoid the above problem?
My add-in installation is with an INNO script.
Thanks for any advice.


RBS