Remove Excel addin completely

C

CB

Hello,

The sample code I found below uninstalls an Excel add-in but leaves it
in the list of available Add-ins.

Im looking for a script to "completely" remove the Excel addin (tidy is
nice!).

I need to do this across a range of users with Office 2003 & 2007 so I
was wanting to reference Excel objects rather than Registry Keys which
vary depending on the Office Version.

Does anyone know if there is code to "completely" remove an Add-in?
Kind Regards
Charlie.B

Dim oXL
Dim crAddin
on error resume next
Set oXL = CreateObject("Excel.Application")
for i = 1 to oXL.Addins.Count
Set crAddin = oXL.Addins.item(i)
If crAddin.Name = "xpaddin.xla" then
crAddin.Installed = False
End If
Next
oXL.Quit
Set oXL = Nothing
 
O

ozgrid.com

Uncheck the add-in from the add-ins dialog, move or delete the add-in from
its folder. Go back to Excel add-ins and check the add-in and say YES to
removing the add-in from the list.
 
C

CB

Thanks! Dave.
You're suggestions are correct but still requires a few simple user
steps to completley remove an Add-in from the Available Add-in's List.
I'm looking for a coded (scripted) way to do the full removal as the
code below only deactivates the Addin and then the user need to follow
the manaul steps.

All ideas welcome.
Charlie.B
 
G

GS

CB brought next idea :
Hello,

The sample code I found below uninstalls an Excel add-in but leaves it in the
list of available Add-ins.

Im looking for a script to "completely" remove the Excel addin (tidy is
nice!).

I need to do this across a range of users with Office 2003 & 2007 so I was
wanting to reference Excel objects rather than Registry Keys which vary
depending on the Office Version.

Does anyone know if there is code to "completely" remove an Add-in?
Kind Regards
Charlie.B

Dim oXL
Dim crAddin
on error resume next
Set oXL = CreateObject("Excel.Application")
for i = 1 to oXL.Addins.Count
Set crAddin = oXL.Addins.item(i)
If crAddin.Name = "xpaddin.xla" then
crAddin.Installed = False
End If
Next
oXL.Quit
Set oXL = Nothing

This is a complex process, but can be done. You'll need to write code
to remove the addin entries in the Registry. There are two keys that
must be edited: 'Add-in Manager' and 'Options'. You'll also need
several declares and constants for using the necessary RegistryAPI
functions, and two separate procedures to remove the Registry entries.
These two procedures will be called from a Main() sub that first checks
the Registry for each version of Excel that may be in use, to determine
if the addin has an entry. This is necessary because each Excel version
has its own Registry key, and you must edit the correct key. Thus, you
may have to check several keys depending on the earliest version of
Excel the addin has been installed to.

If you're not up for messing around in the Registry, post the filename
of your addin and your email address if you want me to send you a
VB6.exe that will do this for you.

Garry
 
C

CB

Hi Gary,

Thank you for your offer of assistance (Appreciated!).

I had a feeling there was no simple answer but thought I'd ask.

After I uninstall the Addin I'll write some nested IF lines (for
different Office versions) to remove from the Add In Manager to complete
the removal.

I very much apprciate your offer of help.
Kind Regards,
Charlie.
 
P

Peter T

It depends where the addin is. If it's in one of the default addin folders
simply remove it (after uninstalling it if not already).
Application.UserLibraryPath and for backwards compatibility
..Application.LibraryPath

If it's not in a default folder it will no longer appear in the addin's
list, however it will still remain in the addins collection and in the
registry (as GS mentioned). First uninstall the addin, either manually or
programmatically. Close *all* instances of Excel. Delete the relevant entry
in this key -

HKEY_CURRENT_USER\Software\Microsoft\Office\X.0\Excel\Add-in Manager

where X is the Excel version, eg 11 for 2003

Regards,
Peter T
 
G

GS

CB was thinking very hard :
Hi Gary,

Thank you for your offer of assistance (Appreciated!).

I had a feeling there was no simple answer but thought I'd ask.

After I uninstall the Addin I'll write some nested IF lines (for different
Office versions) to remove from the Add In Manager to complete the removal.

I very much apprciate your offer of help.
Kind Regards,
Charlie.
Like I said, it's complex and so not going to be as easy as writing
some nested IF constructs. To access the Registry keys you need to edit
requires using several RegistryAPI functions and their relative
constants, and you must ensure you pass their parameters correctly.
There are no built-in VB/VBA functions to do this (i.e.: DeleteSetting
will not work because it won't access the required part of the
Registry).

I use my solution for clients who want an easy way to remove my XLA
addins when no longer used/wanted or the licenses have expired. XLA
type addins do not provide a way of 'auto-uninstalling' via Add/Remove
Programs as do COMAddins. I got this utility from Rob Bovey (it's
author), who made it for his own use. It's specifically designed to
only require the addin's filename, then compile it to a VB6.EXE and
send off to the client. Because he gave it to me for my own personal
use, I think you will understand why I won't give out the code. (The
original VBP contains 4 modules) I also use it as a development tool
for retesting initial startup behavior for XLA type projects. (I keep
refering to anything that is package in a workbook as a 'XLA type'
project, whether or not the "xla" file extension is used)

Peter T gave you one of the keys you need to edit. There is also the
"Options" key to check because if the addin was not uninstalled or
unchecked in the Addin Manager dialog it's entry will be found there. I
realize Peter suggests uninstalling/unchecking it first so you only
have to edit the one Registry key, but you may find it less work and
more convenient to do it all in one place since you MUST edit the
Registry anyway. The utility I use edits both keys and so requires
doing nothing on the part of my clients.

Best of luck in your effort!
Garry
 
C

CB

Many Thanks to Dave, Gary & Peter!
- I appreciate your time given to replying to my question.
Kind Regards from Australia!
Charlie.B
 

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