Remove add-in - also remove toolbar

F

Flemming

Hi,

I have made an Excel Add-In that I instal using an homemade MSI package -
this of cause activates the Add-In in Excel so the user are ready to work...

BUT uninstall... well it works fine - removes the xla file and cleans the
reg.db but the toolbar in Excel remains there..

I can of cause delete the file Excel11.xlb to delete ALL custom toolbars...
but thats really not an option!


Any ideas to how remove the toolbar for my add-in when the uninstaller does
it's job?


Thanks,
Flemming
 
H

Harald Staff

Hi Flemming

Run this little macro here:

Sub Clean()
Dim TB As CommandBar
For Each TB In CommandBars
If TB.BuiltIn = False Then
If MsgBox("Delete " & TB.Name & "?", _
vbYesNo + vbQuestion) = vbYes Then
TB.Delete
End If
End If
Next
End Sub


HTH. Best wishes Harald
 
F

Flemming

Hi Harald

I can remove a toolbar(commandbar) with code from within Excel, but it need
to be something that can be run from the uninstaller and hopefully when
Excel are closed.

/Flemming
 
P

Peter T

If all the (un)installer does is unpack the xla to file and write/remove the
necessary registry entries -
First it should check if Excel is running and if so advise user to quit.
The xla should create and destroy all it's toolbars and buttons in the
respective load/unload events and not in the AddinInstall/Uninstall events.

If the installer creates an automated instance of Excel to install and
uninstall the addin, note that events are disabled. You could use include
Auto_Open and Auto_Close macros to create and destroy menus, see
RunAutoMacros
I can of cause delete the file Excel11.xlb to delete ALL custom
toolbars... but thats really not an option!

No don't do that!

Regards,
Peter T
 
B

Bob Phillips

You should do it in the addin, by adding code in the BeforeClose event of
the addin.

Just give your toolbar a unique tag when you create it and delete it with

Application.Commandbars.FindControl(Tag:="myTag").Delete
 
F

Flemming

Hi Peter and Bob

Of cause - why didn't I think of that my self *s*

Thanks,
Flemming
 
H

Harald Staff

Sorry, sloppy reading at this side.
I don't think an uninstaller can remove things from the toolbar file. As Bob
mentions, a properly written addin should take care of this itself.

Best wishes arald
 

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