[color=darkblue]Option[/color] [color=darkblue]Explicit[/color]
[color=darkblue]Dim[/color] bClose [color=darkblue]As[/color] [color=darkblue]Boolean[/color]
[color=darkblue]Private[/color] [color=darkblue]Sub[/color] Workbook_BeforeClose(Cancel [color=darkblue]As[/color] [color=darkblue]Boolean[/color])
bClose = [color=darkblue]True[/color]
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
[color=darkblue]Private[/color] [color=darkblue]Sub[/color] Workbook_WindowActivate([color=darkblue]ByVal[/color] Wn [color=darkblue]As[/color] Window)
Application.ScreenUpdating = [color=darkblue]False[/color]
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)"
Application.ScreenUpdating = [color=darkblue]True[/color]
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
[color=darkblue]Private[/color] [color=darkblue]Sub[/color] Workbook_WindowDeactivate([color=darkblue]ByVal[/color] Wn [color=darkblue]As[/color] Window)
[color=darkblue]If[/color] bClose [color=darkblue]Then[/color] [color=darkblue]Exit[/color] [color=darkblue]Sub[/color]
[color=darkblue]If[/color] Wn.WindowState = xlMinimized [color=darkblue]Then[/color] [color=darkblue]Exit[/color] [color=darkblue]Sub[/color]
[color=darkblue]Dim[/color] ActWin [color=darkblue]As[/color] Window
[color=darkblue]With[/color] Application
.EnableEvents = [color=darkblue]False[/color]
.ScreenUpdating = [color=darkblue]False[/color]
[color=darkblue]End[/color] [color=darkblue]With[/color]
[color=darkblue]Set[/color] ActWin = ActiveWindow
Wn.Activate
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
ActWin.Activate
[color=darkblue]With[/color] Application
.EnableEvents = [color=darkblue]True[/color]
.ScreenUpdating = [color=darkblue]True[/color]
[color=darkblue]End[/color] [color=darkblue]With[/color]
[color=darkblue]End[/color] [color=darkblue]Sub[/color]