View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Phil Hibbs Phil Hibbs is offline
external usenet poster
 
Posts: 100
Default Add-in doesn't load properly

The problem appears to have gone away today. Maybe Excel had crashed
earlier in the day and was just a bit messed up.

If Addin creating its own menus:
First thing I suggest is to set the IsTemporary property to TRUE, and


Is that a property of the menu item?

add code to delete the menus on shutdown. Compliment that by ensuring
your addin creates new menus on startup only AFTER it deletes them in
that same procedure. This will prevent duplication if the menus already
exist in cases, for example, restart after Excel crashes (if
AutoRecovery is enabled).


I actually started doing that consistently a couple of days ago after
I started getting duplicates!

Sub add_menu()
Call remove_menu
CommandBars("Worksheet Menu Bar") _
.Controls(MENU_NAME) _
.Controls.Add(Type:=msoControlButton) _
.Caption = MENU_ITEM
CommandBars("Worksheet Menu Bar") _
.Controls(MENU_NAME) _
.Controls(MENU_ITEM) _
.OnAction = FUNCTION_NAME
End Sub

Sub remove_menu()
Dim ctl As CommandBarControl
For Each ctl In CommandBars("Worksheet menu
bar").Controls(MENU_NAME).Controls
If ctl.Caption = MENU_ITEM Then
ctl.Delete
End If
Next ctl
End Sub

Phil Hibbs.