Toolbar is floating every time when excel is opened, how to dock?

M

musa.biralo

Hi there,
Macro generates the toolbar and this is done by calling
"create_toolbar" from a module. The call "create_toolbar" is in
"Workbook_Open" event...as a result the toolbar is recreated/
repositioned as floating.... I tried protection/position properties
but ..nothing really helped....

Recreating of toolbar is ok but not the repositioning... Is there a
way to remember the last docking position and save that in the addins
file... so that the x and y or something similar can be pulled from
the xla. OR just to find out the best fit docking position....

your support is triple appreciated. Thanks!

musa.biralo
 
B

Bob Flanagan

If the toolbar already exists, then don't delete and re-create. Just insure
that it is visible.

Bob Flanagan
Macro Systems
144 Dewberry Drive
Hockessin, Delaware, U.S. 19707

Phone: 302-234-9857, cell 302-584-1771
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel
 
J

Jim Rech

You can save your toolbar's position in the registry and restore it from
there like this:

Sub SaveToolbarPos()
With CommandBars("ABC")
SaveSetting "MyUtils", "MyToolbar", "Pos", .Position
SaveSetting "MyUtils", "MyToolbar", "Top", .Top
SaveSetting "MyUtils", "MyToolbar", "Left", .Left
End With
End Sub

Sub SetToolbarPos()
With CommandBars("ABC")
.Position = GetSetting("MyUtils", "MyToolbar", "Pos", msoBarFloating)
.Top = GetSetting("MyUtils", "MyToolbar", "Top", 1)
.Left = GetSetting("MyUtils", "MyToolbar", "Left", 1)
End With
End Sub


--
Jim
| Hi there,
| Macro generates the toolbar and this is done by calling
| "create_toolbar" from a module. The call "create_toolbar" is in
| "Workbook_Open" event...as a result the toolbar is recreated/
| repositioned as floating.... I tried protection/position properties
| but ..nothing really helped....
|
| Recreating of toolbar is ok but not the repositioning... Is there a
| way to remember the last docking position and save that in the addins
| file... so that the x and y or something similar can be pulled from
| the xla. OR just to find out the best fit docking position....
|
| your support is triple appreciated. Thanks!
|
| musa.biralo
|
 
J

Jon Peltier

Change the macro so the commandbar is not floating

MyCmdBar.Position = msoBarFloating '(or 4)

but is docked somewhere

MyCmdBar.Position = msoBarTop '(or 1)

- Jon
 
M

musa.biralo

Hey There Jim,
thanks a lot...
It was perfect solution and perfect match!

I just add one more line then everything worked liked charm!!!!
Thanks again....

Sub SaveToolbarPos()
With CommandBars("ABC")
SaveSetting "MyUtils", "MyToolbar", "Pos", .Position
SaveSetting "MyUtils", "MyToolbar", "Top", .Top
SaveSetting "MyUtils", "MyToolbar", "Left", .Left
SaveSetting "MyUtils", "MyToolbar", "RowIndex", .RowIndex
End With
'DeleteSetting "MyUtils", "MyToolbar"
End Sub

Sub SetToolbarPos()
With CommandBars("IDModeling")
.Position = GetSetting("MyUtils", "MyToolbar", "Pos",
msoBarFloating)
.Top = GetSetting("MyUtils", "MyToolbar", "Top", 1)
.Left = GetSetting("MyUtils", "MyToolbar", "Left", 1)
.RowIndex = GetSetting("MyUtils", "MyToolbar", "RowIndex", 1)
End With
End Sub
 
M

musa.biralo

Hi Bob!

Thanks for the suggestion!..Howevery, that did not work....

Thanks though.

musa.biralo
 
M

musa.biralo

Thanks Jon!

Below was the perfect and i think more advanced solution so i adopt
that...
Thanks for the input.

musa.biralo
 

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