V
VBA_Newbie79
I have adopted some code I received from this forum to create a personalized
toolbar, hide all menus and other toolbars, as well remove the formula bar,
worksheet tabs, and column/row headings.
The code runs in the ThisWorkbook module in both the WindowActivate and
WindowDeactivate events. It works fine flipping between the application and
other Excel files, but refuses to turn the formula bar, worksheet tabs, and
column/row headings back on when I close the file.
I tried including the code in a BeforeClose event, but that doesn't make a
difference. The formula bar, worksheet tabs, and column/row headings will
only turn on via the Tools > Options menu. Have I corrupted something or is
this a "quirk" of Excel?
Below is my code:
----------------------------------------------------
Private Sub Workbook_Windowactivate(ByVal Wn As Excel.Window)
Application.ScreenUpdating = False
Call CreateMenubar
UserToolBars (xlOn)
With ActiveWindow
.DisplayWorkbookTabs = False
.DisplayHeadings = False
End With
With Application
.DisplayFormulaBar = False
.CommandBars("Worksheet Menu Bar").Enabled = False
.ScreenUpdating = True
End With
End Sub
----------------------------------------------------
Private Sub Workbook_WindowDeactivate(ByVal Wn As Excel.Window)
Application.ScreenUpdating = False
Call RemoveMenubar
UserToolBars (xlOff)
With ActiveWindow
.DisplayWorkbookTabs = True
.DisplayHeadings = True
End With
With Application
.DisplayFormulaBar = True
.CommandBars("Worksheet Menu Bar").Enabled = True
.ScreenUpdating = True
End With
End Sub
toolbar, hide all menus and other toolbars, as well remove the formula bar,
worksheet tabs, and column/row headings.
The code runs in the ThisWorkbook module in both the WindowActivate and
WindowDeactivate events. It works fine flipping between the application and
other Excel files, but refuses to turn the formula bar, worksheet tabs, and
column/row headings back on when I close the file.
I tried including the code in a BeforeClose event, but that doesn't make a
difference. The formula bar, worksheet tabs, and column/row headings will
only turn on via the Tools > Options menu. Have I corrupted something or is
this a "quirk" of Excel?
Below is my code:
----------------------------------------------------
Private Sub Workbook_Windowactivate(ByVal Wn As Excel.Window)
Application.ScreenUpdating = False
Call CreateMenubar
UserToolBars (xlOn)
With ActiveWindow
.DisplayWorkbookTabs = False
.DisplayHeadings = False
End With
With Application
.DisplayFormulaBar = False
.CommandBars("Worksheet Menu Bar").Enabled = False
.ScreenUpdating = True
End With
End Sub
----------------------------------------------------
Private Sub Workbook_WindowDeactivate(ByVal Wn As Excel.Window)
Application.ScreenUpdating = False
Call RemoveMenubar
UserToolBars (xlOff)
With ActiveWindow
.DisplayWorkbookTabs = True
.DisplayHeadings = True
End With
With Application
.DisplayFormulaBar = True
.CommandBars("Worksheet Menu Bar").Enabled = True
.ScreenUpdating = True
End With
End Sub