Commandbar Position

  • Thread starter Thread starter jkend69315
  • Start date Start date
J

jkend69315

I asked this question earlier but got no reply. I want my commandbar
(a toolbar attached to a workbook) to always appear as the bottom-most
commandbar at the top of the screen, centered horizontally, when the
workbook opens. Seems like this shouldn't be all that difficult, but
apparently it is a problem in Excel (2002). Thanks! James
 
Try something like this macro below.

Note that attaching commandbars to worksbooks is a bad thing for your end users - much better to
create and delete the commandbar on the fly - lots of code available to show how.

HTH,
Bernie
MS Excel MVP

Sub PositionCommandbar()
Dim cbBar As CommandBar

Set cbBar = Application.CommandBars("Test")

With cbBar
.Visible = True
.Position = msoBarTop
.Left = 2000 'Put it way to the right
.Left = .Left / 2 ' adjust it to the center
End With

End Sub
 
Say I already have a commandbar for which I have created macro calls
and buttons with faces. Is there a way to store and nab this toolbar
and create (install) it instead of having to create the macro calls and
faces everytime? Thanks
 
Try attaching it to the workbook, and use the workbook open event to show it:

Application.CommandBars("Test").Visible = True

And use the workbook close event to delete it.

Application.CommandBars("Test").Visible = False

(Or delete it - it should stay attached to the workbook)

HTH,
Bernie
MS Excel MVP
 

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

Back
Top