View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Nuzza Nuzza is offline
external usenet poster
 
Posts: 7
Default custom toolbars to exclusive files.

Hi Vergel,

Your response was helpful for me but unfortunately it didn't work when I
tried it. I'm using Excel 2003.

I created the toolbar also named "MyCommandBar", then in Visual Basic Editor
pasted your code in the "ThisWorkbook" object. When I closed then reopened
the file, my toolbar had changed and the buttons I had on there were removed,
and replaced by the "New" and "Open" icons. Even when I fixed up the icons on
my toolbar again to the buttons that I want, then close and open the file,
the toolbar reappears with the "New" and "Open" icons and doesn't seem to
save my changes.

Any suggestions with this please?

"Vergel Adriano" wrote:

Peter,

You can create the toolbar everytime the workbook activates and delete it on
deactivate event. Somewhat like this

Private Sub Workbook_Activate()
Dim cmdbar As CommandBar
Set cmdbar = Application.CommandBars.Add("MyCommandBar")
cmdbar.Visible = True
cmdbar.Position = msoBarTop
With Application.CommandBars("Standard")
.Controls(1).Copy bar:=cmdbar
.Controls(2).Copy bar:=cmdbar
End With
End Sub

Private Sub Workbook_Deactivate()
On Error Resume Next
Application.CommandBars("MyCommandBar").Delete
End Sub



--
Hope that helps.

Vergel Adriano


"Peter Lee" wrote:

In Excel 2003,

I was wonder if it was possible to make a custom toolbar to only open in one
file.
Basically, the toolbar is exclusive to the one file.

I don't want to just hide it. I want the toolbar only to work on that one
file and not even exist on other files.