View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bishop Bishop is offline
external usenet poster
 
Posts: 208
Default Initiating a Custom Toolbar

That was exactly it! Corrected the spelling and it works now. Thanks for
pointing that out.

"Dave Peterson" wrote:

Maybe it's because you spelled commandbars incorrectly. And the "on error
resume next" line hid that spelling mistake.

Bishop wrote:

Same problem. Works if the toolbar isn't already present but if it's there I
get a "Invalid procedure call or element" error. Below is my code:

Private Sub Workbook_Open()

Dim cbr As CommandBar

On Error Resume Next
Set cbr = Application.commadbars("CDToolBar")
On Error GoTo 0

If cbr Is Nothing Then
Call CatalystDumpToolBar
Call AddCustomControl
End If

If ThisWorkbook.Name Like "Master*" Then NotSoFast.Show
End Sub

the above code runs even if the toolbar is present and then goes he

Sub CatalystDumpToolBar()

Dim CDToolBar As CommandBar

Set CDToolBar = CommandBars.Add(temporary:=True)
With CDToolBar
.Name = "CDToolBar"
.Position = msoBarTop
.Visible = True
End With
End Sub

This is where I get the error: .Name = "CDToolBar".

"Jim Thomlinson" wrote:

dim cbr as commandbar

on error resume next
set cbr = application.commadbars(x)
on error goto 0

if cbr is nothing then
'open the bar
end if
--
HTH...

Jim Thomlinson


"Bishop" wrote:

I have made a custom toolbar to work with a specific spreadsheet. I need the
toolbar to load if the user doesn't have it already. This is what I'm trying
to do:

Private Sub Workbook_Open()

If "Application.Toolbar X exists" Then "do nothing"
Else: Call "procedure to make toolbar"
End If

End Sub

Just need help filling in the correct syntax to make this work.


--

Dave Peterson