Uninstall Excel Addin

D

Derrick

Hello all;

I have a question about the proper way to uninstall my Excel Addin (.xla
file), developed with VSTO 2003.

My installer will remove the proper files and directorys, and I have a
custom command-line app which adjusts the .NET Configuration Security Policy
correctly (using caspol.exe).

What I want to know is how to keep Excel from trying to load the addin after
it has been uninstalled? Do I have to adjust the registry entry
"HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel\Options\OPEN", or is
there an easier/better way?
 
D

Derrick

Sorry - should've been more clear. I need to do this programmatically,
during the uninstall process of my addin.

Also, I just noticed that the registry key method is not going to work
reliably.

Thanks,

Derrick
 
M

Michel Pierron

Hi Derrick,

It is not easy. The only way that I found to make that is to carry out this
operation by a sending senkeys sequence in Excel. You can create an Excel
file and include the following procedure:

Sub UninstallAddIn()
Const xlaPath = "C:\"
Const xlaFileName = "YourAddin.xla"
Dim I As Integer, Ok As Boolean
DoEvents
With AddIns
For I = 1 To .Count
If .Item(I).Name = xlaFileName Then
..Item(I).Installed = False
Ok = True: Exit For
End If
Next I
If Not Ok Then Exit Sub
On Error Resume Next
Kill xlaPath & xlaFileName
SendKeys "{HOME}"
For I = 1 To .Count
If .Item(I).Name = xlaFileName Then Exit For
SendKeys "{DOWN}"
Next I
SendKeys "~{ESC}"
Application.CommandBars.FindControl(ID:=943).Execute
End With
End Sub

And after, you can run this procedure with a vbs file:

Const xlFileName = "Full path of your Excel file created"
Dim objXl, Fso
Set objXL = WScript.CreateObject("Excel.Application")
objXL.Visible = TRUE ' Or False
objXL.WorkBooks.Open xlFileName
objXL.Run "UninstallAddIn"
objXL.Quit
Set objXL = Nothing
Set Fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
Fso.DeleteFile xlFileName
Set Fso = Nothing
WScript.Quit

It must be possible to include the totality of the code in your desinstaller
if the language used includes the control flow instruction (DoEvents), which
is not the case of vbscript.

MP
 

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