ToolBar Conflict

G

Guest

Hi

In creating a toolbar with the following code if I attempt to
set the position of the toolbar with either of the two methods as
noted below the sheet selector as in clicking on sheet1, sheet2
ect will not work until you enter data in a cell or move or
adjust the page.

Sub NewToolBar()
Dim cbrCommandBar As CommandBar
Dim cbcCommandBarButton As CommandBarButton

' If the command bar exits, remove it.
On Error Resume Next
Application.CommandBars("My CommandBar").Delete

' Add the command bar to the application's
' CommandBars collection.

'With this line the sheet selector works but obviously the bar
'position is default
Set cbrCommandBar = Application.CommandBars.Add("My CommandBar")

If this line of code is un-hyphenated the sheet selector will not work.
'Application.CommandBars("My CommandBar").Position = msoBarTop

If this line of code is used in place of the previous two the
sheet selector will not work.
'Set cbrCommandBar = Application.CommandBars _
'.Add(Name:="My CommandBar", Position:=msoBarTop, Temporary:=True)

cbrCommandBar.Visible = True
End Sub

Sub RemoveCommandBar()
On Error Resume Next
Application.CommandBars("My CommandBar").Delete
End Sub

Doug from this newsgroup tested the procedure on WinXP, XL 2003
without a problem. I tested it on Win98 without a problem. I tested it
on two different computer using Windows XP Home Edition 2002
and it fails or freezes the page selector.
I would appreciate any advice or testing of the procedure. I included
the procedure to delete the toolbar for anyone that test it.

Thanks
TK
 
G

Guest

Hi

In a PS to the previous post, all of the following
settings work except msoBarTop

Set cbrCommandBar = _
Application.CommandBars.Add(Name:="MyCommandBar", Position:=msoBarTop)

'Set cbrCommandBar = _
Application.CommandBars.Add(Name:="MyCommandBar", Position:=msoBarLeft)

'Set cbrCommandBar = _
Application.CommandBars.Add(Name:="MyCommandBar", Position:=msoBarRight)

'Set cbrCommandBar = _
Application.CommandBars.Add(Name:="MyCommandBar", Position:=msoBarBottom)

'Set cbrCommandBar = _
Application.CommandBars.Add(Name:="MyCommandBar", Position:=msoBarFloating)

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top