Addin Uninstalls itself everytime excel is closed

PennStateBrian

New Member
Joined
Aug 27, 2007
Messages
24
Hey everyone,

Have an issue that I think should be simple enough to fix. I have this addin (code below) that I want to be installed everytime I open excel, so that I have the menu item at my disposal. It seems however, whenever I close and reopen excel, the menu item is no longer there, but if I go to tools -> addins, it's still checked. So I have to uncheck it, then click ok, then go back to tools-> addins, reselect it, click ok. And THEN it shows up. Could I please get some guidance. Thanks.

Option Explicit
Dim objHelpMenuItem As CommandBarControl

Private Sub Workbook_AddinInstall()

Dim lngPos As Long
Dim objHelpMenu As CommandBar

Dim objExcelAbout As CommandBarControl

Set objHelpMenu = Application.CommandBars("Tools")

Set objExcelAbout = objHelpMenu.Controls("Macro")
If Not objExcelAbout Is Nothing Then
lngPos = objExcelAbout.Index
Else
lngPos = objHelpMenu.Controls.Count
End If

Set objHelpMenuItem = objHelpMenu.Controls.Add(msoControlButton, 1, , lngPos, True)

objHelpMenuItem.Caption = "Match and Sort..."
objHelpMenuItem.BeginGroup = True
objHelpMenuItem.OnAction = "sortData"


End Sub

Private Sub Workbook_AddinUninstall()

On Error Resume Next
objHelpMenuItem.Delete
On Error GoTo 0

End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Rich (BB code):
Set objHelpMenuItem = objHelpMenu.Controls.Add(msoControlButton, 1, , lngPos, True)
The True argument makes the control temporary, which is not what you want. Change it to False.
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,525
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top