View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Rech Jim Rech is offline
external usenet poster
 
Posts: 2,718
Default 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
|