Dealing with old higher versions in registry

R

RB Smissaert

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\CurrentVersion\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\Excel\Add-in Manager
HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Excel\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\SynergyReportingLoader.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\Excel\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
 

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