B
BEEJAY
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
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