ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Workbook_BeforeClose (https://www.excelbanter.com/excel-programming/410409-workbook_beforeclose.html)

Sandy

Workbook_BeforeClose
 
I have the following :-

Private Sub Workbook_BeforeClose(Cancel As Boolean)

ActiveWorkbook.Unprotect

Application.ScreenUpdating = False
Application.EnableEvents = False


Sheets("Current Round").Unprotect Password:="x"
Sheets("Current Round Detailed").Unprotect Password:="x"
Sheets("Current Round Graph").Unprotect Password:="x"
Sheets("Home Graphs").Unprotect Password:="x"
Sheets("Home Detailed Graphs").Unprotect Password:="x"
Sheets("All Rounds").Unprotect Password:="x"
Sheets("View Rounds").Unprotect Password:="x"
Sheets("Search Rounds").Unprotect Password:="x"
Sheets("LogGraph3").Unprotect Password:="x"

Sheets("Current Round").Visible = False
Sheets("Current Round Detailed").Visible = False
Sheets("Current Round Graph").Visible = False
Sheets("Home Graphs").Visible = False
Sheets("Home Detailed Graphs").Visible = False
Sheets("All Rounds").Visible = False
Sheets("LogGraph3").Visible = True
Sheets("View Rounds").Visible = False
Sheets("Search Rounds").Visible = False

Sheets("RecordOfRounds").Visible = xlSheetVeryHidden
Sheets("RecordOfRoundsDetailed").Visible = xlSheetVeryHidden
Sheets("HomeCourse").Visible = xlSheetVeryHidden
Sheets("HomeDetailed").Visible = xlSheetVeryHidden
Sheets("LogGraph1").Visible = xlSheetVeryHidden
Sheets("LogGraph2").Visible = xlSheetVeryHidden
Sheets("LogGraph4").Visible = xlSheetVeryHidden
Sheets("LogGraph5").Visible = xlSheetVeryHidden
Sheets("LogGraph6").Visible = xlSheetVeryHidden
Sheets("LogGraph7").Visible = xlSheetVeryHidden

'Sheets("Current Round").Select

Dim wksht As Worksheet


With Application
.DisplayFormulaBar = True
.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)"
End With


For Each wksht In Worksheets(Array("Current Round", "Current Round
Detailed", _
"Current Round Graph", "Home Detailed Graphs", "Home Graphs",
"All Rounds", "View Rounds", "Search Rounds"))
wksht.Activate
ActiveWindow.DisplayHeadings = True
Next

Sheets("LogGraph3").Protect Password:="x"

Application.ScreenUpdating = True
Application.EnableEvents = True

ActiveWorkbook.Protect Structu=True, Windows:=False


End Sub

Once this runs the "Do you want to save the changes....." dialog box pops
up.
If the "Yes" button is clicked - fine.
If the "No" button is clicked - fine.
If the "Cancel" button is clicked the visible window does not show the
"Ribbon" nor is the top bar in the Excel application. In short there are no
menus and no exit buttons to close the file or the application.

Is there any way to force the "Ribbon" to display in order to access the
Close buttons.

Any help is appreciated.
Sandy




All times are GMT +1. The time now is 09:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com