Do Until ??
Beejay,
If the new command bars are attached to the workbook, then they will
appear automatically. They do not have to made visible.
You however, should still delete them when the workbook closes.
As far as hiding the built-in toolbars, this is not good practice as all workbooks
in the application will have the toolbars hidden.
Alternatively, you might want to just hide the "Standard" and "Formatting" toolbars.
Jim Cone
San Francisco, USA
"BEEJAY"
wrote in message
Used info from J. Walks Dummies Excel VBA Programming.
Open workbook: Remove "standard" toolbars
Close WorkBook Re-Install the "standard" toolbars.
That works Great.
Then I tried to add Install my special toolbars under
Open Work Book and things went nuts.
My combined process, as shown below is obviously flawed.
The install special toolbars should not occur til the "standard" toolbar
removal process is completed and stops executing.
I expect that "do until" would work OK, but I don't now how to build
that in.
OR, If there is an easier, or more efficient way, thats find too.
I don't expect a problem with the closing sequence.
Option Explicit
Private Sub Workbook_Open()
Dim TBarCount As Integer
Dim cbar As CommandBar
Sheets("Sheet1").Range("A:A").ClearContents
TBarCount = 0
For Each cbar In Application.CommandBars
If cbar.Type = msoBarTypeNormal Then
If cbar.Visible Then
TBarCount = TBarCount + 1
Sheets("Sheet1").Cells(TBarCount, 1) = _
cbar.Name
cbar.Visible = False
End If
End If
Next cbar
Application.CommandBars("JFS-C1").Visible = True
Application.CommandBars("JFS-C2").Visible = True
Application.CommandBars("JFS-C3").Visible = True
Application.CommandBars("Protection").Visible = True
Application.CommandBars("JFS-Comments").Visible = True
Application.CommandBars("JFS-Macros").Visible = True
Application.CommandBars("JFS-Private").Visible = True
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("JFS-C1").Delete
Application.CommandBars("JFS-C2").Delete
Application.CommandBars("JFS-C3").Delete
Application.CommandBars("Protection").Delete
Application.CommandBars("JFS-Comments").Delete
Application.CommandBars("JFS-Macros").Delete
Application.CommandBars("JFS-Private").Delete
Dim Row As Long
Dim TBar As String
Row = 1
TBar = Sheets("Sheet1").Cells(Row, 1)
Do While TBar < ""
Application.CommandBars(TBar).Visible = True
Row = Row + 1
TBar = Sheets("Sheet1").Cells(Row, 1)
Loop
End Sub
|