Sub ShowHideToolbars()
Dim cbar As Object, cB As Variant, bars() As String
Dim strSavedBars$
strSavedBars = GetSetting("ShowHideToolbars", "ToolbarState", "Toolbars")
If strSavedBars <> "" Then
For Each cB In Split(strSavedBars, ":")
CommandBars(cB).Visible = True
Next cB
SaveSetting "ShowHideToolbars", "ToolbarState", "Toolbars", ""
Else
nCount = CommandBars.Count: nSavedCount = 0
ReDim bars(0 To nCount - 1)
For n = 1 To nCount
With CommandBars(n)
If .Name <> "Status Bar" Then _
If .Visible Then .Visible = False: bars(nSavedCount) = .Name: nSavedCount = nSavedCount + 1
End With
Next n
ReDim Preserve bars(0 To nSavedCount - 1)
SaveSetting "ShowHideToolbars", "ToolbarState", "Toolbars", Join(bars, ":")
SendKeys "{ESC 10}"
End If
End Sub