Set custom ToolBar Position on Excel Loads default to zero value

  • Thread starter John Stratoudakis
  • Start date
J

John Stratoudakis

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
 
B

Bernie Deitrick

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
 
Top