LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Adding and Deleting custom commandbars

The code I have currently in an addin is below. What I am finding is that
sometimes Excel doesn't close properly or for any other reason the adding of
these command bars becomes duplicated. I have had to remove up to twenty on
some of my staffs computers. How can I write this so that it checks to see
if the command bar exists and if it does to not add it again?

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("Worksheet Menu Bar"). _
Controls("Tools").Controls("Import DR Data File").Delete
Application.CommandBars("Worksheet Menu Bar"). _
Controls("Tools").Controls("Daily Revenue Reset").Delete
End Sub

Private Sub Workbook_Open()

Set newmenuitem = Application.CommandBars _
("Worksheet Menu Bar").Controls("Tools").Controls.Add
With newmenuitem
.Caption = "Import DR Data File"
.FaceId = 312
.BeginGroup = True
.OnAction = "MorningReport"
End With
Set newmenuitem = Application.CommandBars _
("Worksheet Menu Bar").Controls("Tools").Controls.Add

With newmenuitem
.Caption = "Daily Revenue Reset"
.FaceId = 1678
.BeginGroup = False
.OnAction = "reset_morning_reports"
End With

End Sub
--
Thanks!
Shane W
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CommandBars & Custom John JBM Excel Programming 1 May 16th 07 05:44 PM
Bulk-Delete All Custom Commandbars KL[_6_] Excel Programming 4 December 10th 04 01:39 PM
Prob: Custom CommandBars and .xls Files Being Re-Opened James Cox[_2_] Excel Programming 0 October 19th 04 03:34 PM
Custom faces for custom menus/commandbars Stu Valentine Excel Programming 1 September 17th 04 04:28 AM
Question on custom commandbars Mark Reynolds Excel Programming 3 January 23rd 04 11:55 PM


All times are GMT +1. The time now is 11:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"