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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,701
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,685
Messages
5,637,808
Members
416,983
Latest member
LessThanAverageUser

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
Top