![]() |
Get floating CommandBar position
After I manually move my custom command bar to the place I want it, is there
a command I can type in the immediate window to get the .Top and .Left positions? Thanks, Patti |
Get floating CommandBar position
"Patti" wrote in message
... After I manually move my custom command bar to the place I want it, is there a command I can type in the immediate window to get the .Top and .Left positions? Hi Patti, Here's one way to do it: ? CommandBars("YourBarName").Top ? CommandBars("YourBarName").Left -- Rob Bovey, Excel MVP Application Professionals http://www.appspro.com/ * Take your Excel development skills to the next level. * Professional Excel Development http://www.appspro.com/Books/Books.htm |
Get floating CommandBar position
Hi Rob,
When I try that, I get a compile error: "Expected variable or procedure, not module". I have tried both ? commandbars(myapp).top and ? commandbars("My Toolbar").top. Partial code - pinched from Bob Phillips - follows. Any ideas? Thanks! Patti Private Sub Workbook_Open() 'Bob Phillips Dim oCB As CommandBar appMenu = "My Toolbar" On Error Resume Next Application.CommandBars(appMenu).Delete On Error GoTo 0 Set oCB = Application.CommandBars.Add(Name:=appMenu, Position:=msoBarFloating, temporary:=True) With oCB With .Controls.Add(Type:=msoControlButton) .Caption = appMenu & " Toolbar" .Style = msoButtonCaption End With '. '. ' more controls added '. .Visible = True End With End Sub "Rob Bovey" wrote in message ... "Patti" wrote in message ... After I manually move my custom command bar to the place I want it, is there a command I can type in the immediate window to get the .Top and .Left positions? Hi Patti, Here's one way to do it: ? CommandBars("YourBarName").Top ? CommandBars("YourBarName").Left -- Rob Bovey, Excel MVP Application Professionals http://www.appspro.com/ * Take your Excel development skills to the next level. * Professional Excel Development http://www.appspro.com/Books/Books.htm |
Get floating CommandBar position
Did you try Rob's suggestion after you ran Bob's code?
I included Rob's suggestion into Bob's code and it still worked. Option Explicit Private Sub Workbook_Open() 'Bob Phillips Dim oCB As CommandBar Dim appMenu As String appMenu = "My Toolbar" On Error Resume Next Application.CommandBars(appMenu).Delete On Error GoTo 0 Set oCB = Application.CommandBars.Add(Name:=appMenu, _ Position:=msoBarFloating, temporary:=True) With oCB With .Controls.Add(Type:=msoControlButton) .Caption = appMenu & " Toolbar" .Style = msoButtonCaption End With '. '. ' more controls added '. .Visible = True MsgBox .Top & vbLf & .Left End With End Sub Patti wrote: Hi Rob, When I try that, I get a compile error: "Expected variable or procedure, not module". I have tried both ? commandbars(myapp).top and ? commandbars("My Toolbar").top. Partial code - pinched from Bob Phillips - follows. Any ideas? Thanks! Patti Private Sub Workbook_Open() 'Bob Phillips Dim oCB As CommandBar appMenu = "My Toolbar" On Error Resume Next Application.CommandBars(appMenu).Delete On Error GoTo 0 Set oCB = Application.CommandBars.Add(Name:=appMenu, Position:=msoBarFloating, temporary:=True) With oCB With .Controls.Add(Type:=msoControlButton) .Caption = appMenu & " Toolbar" .Style = msoButtonCaption End With '. '. ' more controls added '. .Visible = True End With End Sub "Rob Bovey" wrote in message ... "Patti" wrote in message ... After I manually move my custom command bar to the place I want it, is there a command I can type in the immediate window to get the .Top and .Left positions? Hi Patti, Here's one way to do it: ? CommandBars("YourBarName").Top ? CommandBars("YourBarName").Left -- Rob Bovey, Excel MVP Application Professionals http://www.appspro.com/ * Take your Excel development skills to the next level. * Professional Excel Development http://www.appspro.com/Books/Books.htm -- Dave Peterson |
Get floating CommandBar position
"Patti" wrote in message
... Hi Rob, When I try that, I get a compile error: "Expected variable or procedure, not module". I have tried both ? commandbars(myapp).top and ? commandbars("My Toolbar").top. Hi Patti, It sounds like you've named one of your code modules CommandBars. This is confusing VBA because it thinks you're trying to reference a procedure in that module. Rename the module to something like MCommandBars and try it again. -- Rob Bovey, Excel MVP Application Professionals http://www.appspro.com/ * Take your Excel development skills to the next level. * Professional Excel Development http://www.appspro.com/Books/Books.htm |
All times are GMT +1. The time now is 03:23 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com