View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
dim dim is offline
external usenet poster
 
Posts: 123
Default MAJOR PROBLEM! --- Menu Bars don't unhide?

I made up my own recording of the menu bars using IF statements and put it
into the Workbook Close event. Its below if anyone is interested. It works
fine so I'm going to expand it to include gridlines and such.

Can someone tell me whether the Workbook_BeforeClose event or the Auto_Close
procedure executes first?
Thanks.

----------------------------------------------------------------------------------------

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.ScreenUpdating = False
Sheets("Bars").Select

Application.CommandBars("Worksheet Menu Bar").Enabled = True

If Range("B20").Value = 1 Then
Application.DisplayFormulaBar = True
End If
If Range("B21").Value = 1 Then
Application.DisplayStatusBar = True
End If
If Range("B1").Value = 1 Then
Application.CommandBars("Standard").Visible = True
End If
If Range("B2").Value = 1 Then
Application.CommandBars("Formatting").Visible = True
End If
If Range("B3").Value = 1 Then
Application.CommandBars("Forms").Visible = True
End If
If Range("B4").Value = 1 Then
Application.CommandBars("Borders").Visible = True
End If
If Range("B5").Value = 1 Then
Application.CommandBars("Chart").Visible = True
End If
If Range("B6").Value = 1 Then
Application.CommandBars("Control Toolbox").Visible = True
End If
If Range("B7").Value = 1 Then
Application.CommandBars("Drawing").Visible = True
End If
If Range("B8").Value = 1 Then
Application.CommandBars("Exit Design Mode").Visible = True
End If
If Range("B9").Value = 1 Then
Application.CommandBars("External Data").Visible = True
End If
If Range("B10").Value = 1 Then
Application.CommandBars("Formula Auditing").Visible = True
End If
If Range("B11").Value = 1 Then
Application.CommandBars("Picture").Visible = True
End If
If Range("B12").Value = 1 Then
Application.CommandBars("PivotTable").Visible = True
End If
If Range("B13").Value = 1 Then
Application.CommandBars("Protection").Visible = True
End If
If Range("B14").Value = 1 Then
Application.CommandBars("Reviewing").Visible = True
End If
If Range("B15").Value = 1 Then
Application.CommandBars("Text To Speech").Visible = True
End If
If Range("B16").Value = 1 Then
Application.CommandBars("Visual Basic").Visible = True
End If
If Range("B17").Value = 1 Then
Application.CommandBars("Watch Window").Visible = True
End If
If Range("B18").Value = 1 Then
Application.CommandBars("Web").Visible = True
End If
If Range("B19").Value = 1 Then
Application.CommandBars("WordArt").Visible = True
End If

Sheets("Sheet1").Select
Application.ScreenUpdating = True

End Sub

Private Sub Workbook_Open()
Application.ScreenUpdating = False

Sheets("Bars").Select
Range("A1:A21").ClearContents

Application.CommandBars("Worksheet Menu Bar").Enabled = False

If Application.DisplayFormulaBar = True Then
Range("B20").Value = 1
Application.DisplayFormulaBar = False
End If
If Application.DisplayStatusBar = True Then
Range("B21").Value = 1
End If
If Application.CommandBars("Standard").Visible = True Then
Range("B1").Value = 1
Application.CommandBars("Standard").Visible = False
End If
If Application.CommandBars("Formatting").Visible = True Then
Range("B2").Value = 1
Application.CommandBars("Formatting").Visible = False
End If
If Application.CommandBars("Forms").Visible = True Then
Range("B3").Value = 1
Application.CommandBars("Forms").Visible = False
End If
If Application.CommandBars("Borders").Visible = True Then
Range("B4").Value = 1
Application.CommandBars("Borders").Visible = False
End If
If Application.CommandBars("Chart").Visible = True Then
Range("B5").Value = 1
Application.CommandBars("Chart").Visible = False
End If
If Application.CommandBars("Control Toolbox").Visible = True Then
Range("B6").Value = 1
Application.CommandBars("Control Toolbox").Visible = False
End If
If Application.CommandBars("Drawing").Visible = True Then
Range("B7").Value = 1
Application.CommandBars("Drawing").Visible = False
End If
If Application.CommandBars("Exit Design Mode").Visible = True Then
Range("B8").Value = 1
Application.CommandBars("Exit Design Mode").Visible = False
End If
If Application.CommandBars("External Data").Visible = True Then
Range("B9").Value = 1
Application.CommandBars("External Data").Visible = False
End If
If Application.CommandBars("Formula Auditing").Visible = True Then
Range("B10").Value = 1
Application.CommandBars("Formula Auditing").Visible = False
End If
If Application.CommandBars("Picture").Visible = True Then
Range("B11").Value = 1
Application.CommandBars("Picture").Visible = False
End If
If Application.CommandBars("PivotTable").Visible = True Then
Range("B12").Value = 1
Application.CommandBars("PivotTable").Visible = False
End If
If Application.CommandBars("Protection").Visible = True Then
Range("B13").Value = 1
Application.CommandBars("Protection").Visible = False
End If
If Application.CommandBars("Reviewing").Visible = True Then
Range("B14").Value = 1
Application.CommandBars("Reviewing").Visible = False
End If
If Application.CommandBars("Text To Speech").Visible = True Then
Range("B15").Value = 1
Application.CommandBars("Text To Speech").Visible = False
End If
If Application.CommandBars("Visual Basic").Visible = True Then
Range("B16").Value = 1
Application.CommandBars("Visual Basic").Visible = False
End If
If Application.CommandBars("Watch Window").Visible = True Then
Range("B17").Value = 1
Application.CommandBars("Watch Window").Visible = False
End If
If Application.CommandBars("Web").Visible = True Then
Range("B18").Value = 1
Application.CommandBars("Web").Visible = False
End If
If Application.CommandBars("WordArt").Visible = True Then
Range("B19").Value = 1
Application.CommandBars("WordArt").Visible = False
End If

Sheets("Sheet1").Select
Application.ScreenUpdating = True

End Sub