ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Set custom ToolBar Position on Excel Loads default to zero value (https://www.excelbanter.com/excel-programming/306413-set-custom-toolbar-position-excel-loads-default-zero-value.html)

John Stratoudakis

Set custom ToolBar Position on Excel Loads default to zero value
 
I am writing an Excel Add-In that creates a custom toolbar on load
whose position is saved to the registry on exit.

However, whenever I place the toolbar on the 1st or 2nd row (usually
on the same row with the Standard & Formatting Excel Toolbars), the
Top position is properly stored into the registry as Long (23), but
when the application loads again, setting the toolbar .top property to
23 results in the toolbar being set to the value of 75. This happens
even though I am setting the Toolbar with a Long value of 23.


Excel 2000
VB6

Does anybody know anything about this? Is this because I am not
allowed to place a custom (or temporary) toolbar on the same row as a
built in Excel toolbar?

-- snip --

ToolbarTop = GetSetting(RegSettings.cToolBarTop)
If Not Len(ToolbarTop) 0 Then
oBar.Top = 100
End If

With oBar
.Position = ToolbarPosition
.Top = CLng(ToolbarTop)
.Left = CLng(ToolbarLeft)
.Visible = ToolbarVisibility
End With

-- snip --



Thanks,

John

Bernie Deitrick

Set custom ToolBar Position on Excel Loads default to zero value
 
John,

You need to set the row property: this code will add a new commandbar just
to the right of the formatting commandbar.

Sub MakeCB()
Dim cmdToolbar As CommandBar
Set cmdToolbar = Application.CommandBars.Add _
(Name:="MyBar", Temporary:=True)

With cmdToolbar
.Position = msoBarTop
.Left = (Application.CommandBars("Formatting").Left _
+ Application.CommandBars("Formatting").Width)
.RowIndex = Application.CommandBars("Formatting").RowIndex
.Visible = True
End With
End Sub

HTH,
Bernie
MS Excel MVP

"John Stratoudakis" wrote in message
om...
I am writing an Excel Add-In that creates a custom toolbar on load
whose position is saved to the registry on exit.

However, whenever I place the toolbar on the 1st or 2nd row (usually
on the same row with the Standard & Formatting Excel Toolbars), the
Top position is properly stored into the registry as Long (23), but
when the application loads again, setting the toolbar .top property to
23 results in the toolbar being set to the value of 75. This happens
even though I am setting the Toolbar with a Long value of 23.


Excel 2000
VB6

Does anybody know anything about this? Is this because I am not
allowed to place a custom (or temporary) toolbar on the same row as a
built in Excel toolbar?

-- snip --

ToolbarTop = GetSetting(RegSettings.cToolBarTop)
If Not Len(ToolbarTop) 0 Then
oBar.Top = 100
End If

With oBar
.Position = ToolbarPosition
.Top = CLng(ToolbarTop)
.Left = CLng(ToolbarLeft)
.Visible = ToolbarVisibility
End With

-- snip --



Thanks,

John





All times are GMT +1. The time now is 08:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com