![]() |
Initiating a Custom Toolbar
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. |
Initiating a Custom Toolbar
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. |
Initiating a Custom Toolbar
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. |
Initiating a Custom Toolbar
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 |
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 |
All times are GMT +1. The time now is 04:29 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com