Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Disappearing custom menu and custom toolbar
Hi:
I have a wired problem with my Macro I generated, (running in Excel 2000) This macro is copied to XLStart Folder. and I have this macro installed on 3 user's computers. However on one of the user, my custom menu and toolbar disappears from time-to-time: This is how the process works: There is an external web base software application user will run and this software generates their reports in Excel format. So when user runs reports for multiple accounts, it creates these reports and loaded in Excel (same layout except different info on each excel file) This application also has a custom menu, so WHEN USERS SWITCH TO THESE EXCEL REPORTS, THEY WILL SEE THE CUSTOM MENU FROM THAT APPLICATION AS WELL AS MY CUSTOM MENU AND TOOLBAR. Only one user has a problem, NOT DURING THE INITIALLY, only after she closes few excel reports, then at some point MY CUSTOM MENU AND TOOLBAR DISAPPEARS TOO. THE MOST WIRED PROBLEM IS THAT THIS IS NOT CONSISTENT, SOME DAY IT'S OK AND SOME DAY IT'S NOT. AND THE OTHER 2 USERS HAD NEVER EXPERIENCE THIS PROBLEM. This is really wired and I did checked, all the users has the same excel version. Here's my code in creating custom menu and custom toolbar, I couldn't find anything wrong with it, maybe some expert might be, it wouldbe really helpful if you do. ===================== Code in ThisWorkBook ===================== Private Sub Workbook_BeforeClose(Cancel As Boolean) Call RemoveCustomMenu Call Toolbar_OFF End Sub Private Sub Workbook_Open() Call AddCustomMenu Call Toolbar_ON End Sub ======================= Code in My Macro Module ======================= Public Sub AddCustomMenu() Call RemoveCustomMenu 'Remove custom menu if already exist Dim cbWSMenuBar As CommandBar Dim muCustom As CommandBarControl Dim iHelpIndex As Integer ' 'Add custom menu to "Worksheet Menu Bar" ' Set cbWSMenuBar = Application.CommandBars("Worksheet Menu Bar") iHelpIndex = cbWSMenuBar.Controls("Help").Index Set muCustom = cbWSMenuBar.Controls.Add(Type:=msoControlPopup, Befo=iHelpIndex) With muCustom .Caption = "&Cus-Macro" With .Controls.Add(Type:=msoControlButton) .Caption = "&Run Format Current Report" .FaceId = 550 .OnAction = "CusMacro.BOMacro" End With With .Controls.Add(Type:=msoControlButton) .Caption = "&Reserve for Future Use" .BeginGroup = True .FaceId = 1296 .OnAction = "" End With End With End Sub Public Sub RemoveCustomMenu() Dim cbWSMenuBar As CommandBar ' 'Remove Custom Menu from "Worksheet Menu Bar" ' On Error Resume Next Set cbWSMenuBar = CommandBars("Worksheet Menu Bar") cbWSMenuBar.Controls("Cus-Macro").Delete End Sub Sub Toolbar_OFF() Dim bar As CommandBar ' Delete the Commandbar if it already exists For Each bar In Application.CommandBars If bar.Name = cCommandBar Then bar.Delete Next End Sub Sub Toolbar_ON() Dim bar As CommandBar Toolbar_OFF Set bar = Application.CommandBars.Add(Name:=cCommandBar, Position:=msoBarTop, Temporary:=True) ' Button With bar.Controls.Add(Type:=msoControlButton) .FaceId = 550 .Caption = "Cus-Macro" .Style = msoButtonIconAndCaption .OnAction = "CusMacro.BOMacro" End With CommandBars("Cus-Macro").Visible = True End Sub Thank you. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
custom toolbar | Excel Discussion (Misc queries) | |||
Adding a check mark to the custom made toolbar/menu continue...... | Excel Programming | |||
Custom Menu return to Excel Menu upon Closing | Excel Programming | |||
custom toolbar buttons are saved where? Excel loads twice bymistake and all my custom toolbar buttons get gone!!! | Excel Programming | |||
saving toolbar buttons on custom toolbar | Excel Programming |