Michael
Here is a starter for 10... you could of course put the code in the first
sub in the Workbook_Open() event and the second code into the
Workbook_BeforeClose() event, but I list it below in separate subs. (It
places the names of the CommandBars on a veryhidden sheet)
Sub Dictator()
Dim stateStore As Worksheet
Dim cmBar As CommandBar
Dim x As Integer
Set stateStore = Worksheets.Add
stateStore.Name = "StateStore"
stateStore.Visible = xlSheetVeryHidden
With Application
.Caption = "My Application"
.DisplayFormulaBar = False
.DisplayScrollBars = False
.DisplayStatusBar = False
.WindowState = xlMaximized
End With
With ActiveWindow
.DisplayHeadings = False
.DisplayWorkbookTabs = False
End With
For Each cmBar In Application.CommandBars
If cmBar.Visible Then
stateStore.Range("A" & x + 1).Value = cmBar.Name
cmBar.Enabled = False
x = x + 1
End If
Next cmBar
End Sub
Sub UndoDictator()
Dim stateStore As Worksheet
Dim myCell As Range
Set stateStore = Worksheets("StateStore")
With Application
.Caption = ""
.DisplayFormulaBar = True
.DisplayScrollBars = True
.DisplayStatusBar = True
End With
With ActiveWindow
.DisplayHeadings = True
.DisplayWorkbookTabs = True
End With
For Each myCell In Worksheets("StateStore").UsedRange
Application.CommandBars(myCell.Text).Enabled = True
Next myCell
With Application
.DisplayAlerts = False
With stateStore
.Visible = xlSheetVisible
.Delete
End With
.DisplayAlerts = True
End With
End Sub
--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
web:
www.nickhodge.co.uk
blog:
www.nickhodge.co.uk/blog/
FREE UK OFFICE USER GROUP MEETING, MS READING, 27th APRIL 2007
www.officeusergroup.co.uk