![]() |
command bar problem
hi all,
i'm having a command bar problem. i have made a custom command bar, added it to my excel application. it comes nicely just above the formula bar with all the buttons that i have added. The problem starts when i open another workbook with same code (i.e. an earlier version or something), now i get another command bar with all the buttons again and so no i have 2 command bars and duplication of buttons and of course it looks ugly. similarily when i close one of the workbooks now, both the command bars disappear. so then i wont have any buttons !!.. i am loading this commandbar in ThisWorkbook module. i know that if i have the command bar loaded thru ThisWorkbook module then whenever i open a workbook with that ThisWorkbook module, the command bar will be loaded but i dont want that. i want only 1 command bar here's my code ---------------------------------------- Public Sub Workbook_Open() Call Buttons End Sub Private Sub Workbook_Activate() On Error Resume Next Application.CommandBars("Resource").Enabled = True End Sub Private Sub Workbook_Deactivate() On Error Resume Next Application.CommandBars("Resource").Enabled = False End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error Resume Next Application.CommandBars("Resource").Delete End Sub and in Buttons sub i add buttons to the Resource command bar like this Application.CommandBars.Add("Resource",Position:=m soBarTop, temporary:=True) any help will be appreciated. amit |
command bar problem
The thing that's odd about your post is that you're suggesting that you have
two commandbars with the same name. That's not possible, as far as I know. For instance this simple code errors on the second line: Sub a() CommandBars.Add "ABC" CommandBars.Add "ABC" End Sub -- Jim "helpwithXL" wrote in message oups.com... | hi all, | i'm having a command bar problem. i have made a custom command bar, | added it to my excel application. it comes nicely just above the | formula bar with all the buttons that i have added. The problem starts | when i open another workbook with same code (i.e. an earlier version or | something), now i get another command bar with all the buttons again | and so no i have 2 command bars and duplication of buttons and of | course it looks ugly. similarily when i close one of the workbooks now, | both the command bars disappear. so then i wont have any buttons !!.. | i am loading this commandbar in ThisWorkbook module. i know that if i | have the command bar loaded thru ThisWorkbook module then whenever i | open a workbook with that ThisWorkbook module, the command bar will be | loaded but i dont want that. i want only 1 command bar | here's my code ---------------------------------------- | Public Sub Workbook_Open() | Call Buttons | End Sub | | Private Sub Workbook_Activate() | On Error Resume Next | Application.CommandBars("Resource").Enabled = True | End Sub | | Private Sub Workbook_Deactivate() | On Error Resume Next | Application.CommandBars("Resource").Enabled = False | End Sub | | Private Sub Workbook_BeforeClose(Cancel As Boolean) | On Error Resume Next | Application.CommandBars("Resource").Delete | End Sub | | and in Buttons sub i add buttons to the Resource command bar like this | Application.CommandBars.Add("Resource",Position:=m soBarTop, | temporary:=True) | | any help will be appreciated. | amit | |
command bar problem
thanx for the reply Jim,
I must have lost u in a such a big explanation of my problem. Sorry. I'll try to be clearer this time. I'm not suggesting that i'm adding 2 commandbars (with or without same name). i have only 1 commandbar by the name "Resource". I'm getting duplicate commandbars when i open 2 workbooks simultaneously and these 2 WBs are versions of the same code. so when i open WB ver 1.1, i get my commandbar nice and proper but now i have WB1.2 in which i have changed some code (i didn't change any code corresponding to commandbars). now I've to open this WB1.2 to copy a few sheets into it from WB1.1. so the situation is that WB1.1 is already open and when i open WB1.2 (with WB1.1 also open), i get the commandbar "Resource" again, so i have 2 commandbars exactly same and i'm not sure how to have only 1 commandbar. i tried to get the name of commandbar b4 loading any commandbar (which i thought was the logical solution) but to my surprise, it didn't work. can you help. i hope i didn't overdo my explanation again. regards, amit |
All times are GMT +1. The time now is 02:43 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com