Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have the following but it does not run when closing workbook - Any ideas?
(I am assuming the message box should pop up?) Private Sub Workbook_BeforeClose(Cancel As Boolean) MsgBox "Hello" Application.ScreenUpdating = False Application.EnableEvents = False Sheets("Current Round").Unprotect Password:="xxxxx" Sheets("Current Round Detailed").Unprotect Password:="xxxxx" Sheets("Current Round Graph").Unprotect Password:="xxxxx" Sheets("Home Graphs").Unprotect Password:="xxxxx" Sheets("Home Detailed Graphs").Unprotect Password:="xxxxx" Sheets("All Rounds").Unprotect Password:="xxxxx" Sheets("View Rounds").Unprotect Password:="xxxxx" Sheets("Current Round").Visible = True Sheets("Current Round Detailed").Visible = True Sheets("Current Round Graph").Visible = True Sheets("Home Graphs").Visible = True Sheets("Home Detailed Graphs").Visible = True Sheets("All Rounds").Visible = True Sheets("View Rounds").Visible = True 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("LogGraph3").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 .CommandBars("Worksheet Menu Bar").Enabled = True .CommandBars("Standard").Visible = True .CommandBars("Formatting").Visible = True .CommandBars("Drawing").Visible = 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", "LogGraph3")) Wksht.Activate ActiveWindow.DisplayHeadings = True Next Application.ScreenUpdating = True Application.EnableEvents = True End Sub Thanks Sandy |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
If this isn't running and I agree it should pop up the message box then events may be disabled. rRght click any sheet tab, view code and paste this in and run it Sub enableem() Application.EnableEvents = True End Sub then try you before_close routine again. When disbling events using code you should do so at the last point in the code possible. If you disable early and the code crashes you can be left with events disabled. Mike "Sandy" wrote: I have the following but it does not run when closing workbook - Any ideas? (I am assuming the message box should pop up?) Private Sub Workbook_BeforeClose(Cancel As Boolean) MsgBox "Hello" Application.ScreenUpdating = False Application.EnableEvents = False Sheets("Current Round").Unprotect Password:="xxxxx" Sheets("Current Round Detailed").Unprotect Password:="xxxxx" Sheets("Current Round Graph").Unprotect Password:="xxxxx" Sheets("Home Graphs").Unprotect Password:="xxxxx" Sheets("Home Detailed Graphs").Unprotect Password:="xxxxx" Sheets("All Rounds").Unprotect Password:="xxxxx" Sheets("View Rounds").Unprotect Password:="xxxxx" Sheets("Current Round").Visible = True Sheets("Current Round Detailed").Visible = True Sheets("Current Round Graph").Visible = True Sheets("Home Graphs").Visible = True Sheets("Home Detailed Graphs").Visible = True Sheets("All Rounds").Visible = True Sheets("View Rounds").Visible = True 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("LogGraph3").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 .CommandBars("Worksheet Menu Bar").Enabled = True .CommandBars("Standard").Visible = True .CommandBars("Formatting").Visible = True .CommandBars("Drawing").Visible = 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", "LogGraph3")) Wksht.Activate ActiveWindow.DisplayHeadings = True Next Application.ScreenUpdating = True Application.EnableEvents = True End Sub Thanks Sandy |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Mike
Yes my stupidity, events had been turned off in the Workbook_Open. Thanks Sandy "Mike H" wrote in message ... Hi, If this isn't running and I agree it should pop up the message box then events may be disabled. rRght click any sheet tab, view code and paste this in and run it Sub enableem() Application.EnableEvents = True End Sub then try you before_close routine again. When disbling events using code you should do so at the last point in the code possible. If you disable early and the code crashes you can be left with events disabled. Mike "Sandy" wrote: I have the following but it does not run when closing workbook - Any ideas? (I am assuming the message box should pop up?) Private Sub Workbook_BeforeClose(Cancel As Boolean) MsgBox "Hello" Application.ScreenUpdating = False Application.EnableEvents = False Sheets("Current Round").Unprotect Password:="xxxxx" Sheets("Current Round Detailed").Unprotect Password:="xxxxx" Sheets("Current Round Graph").Unprotect Password:="xxxxx" Sheets("Home Graphs").Unprotect Password:="xxxxx" Sheets("Home Detailed Graphs").Unprotect Password:="xxxxx" Sheets("All Rounds").Unprotect Password:="xxxxx" Sheets("View Rounds").Unprotect Password:="xxxxx" Sheets("Current Round").Visible = True Sheets("Current Round Detailed").Visible = True Sheets("Current Round Graph").Visible = True Sheets("Home Graphs").Visible = True Sheets("Home Detailed Graphs").Visible = True Sheets("All Rounds").Visible = True Sheets("View Rounds").Visible = True 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("LogGraph3").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 .CommandBars("Worksheet Menu Bar").Enabled = True .CommandBars("Standard").Visible = True .CommandBars("Formatting").Visible = True .CommandBars("Drawing").Visible = 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", "LogGraph3")) Wksht.Activate ActiveWindow.DisplayHeadings = True Next Application.ScreenUpdating = True Application.EnableEvents = True End Sub Thanks Sandy |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"had been turned off in the Workbook_Open"
Sandy, I believe it is better to say that when events are turned off ALL EVENTS are turned off, not just the Workbook_Open. << FWIW Jim "Sandy" wrote: Hi Mike Yes my stupidity, events had been turned off in the Workbook_Open. Thanks Sandy "Mike H" wrote in message ... Hi, If this isn't running and I agree it should pop up the message box then events may be disabled. rRght click any sheet tab, view code and paste this in and run it Sub enableem() Application.EnableEvents = True End Sub then try you before_close routine again. When disbling events using code you should do so at the last point in the code possible. If you disable early and the code crashes you can be left with events disabled. Mike "Sandy" wrote: I have the following but it does not run when closing workbook - Any ideas? (I am assuming the message box should pop up?) Private Sub Workbook_BeforeClose(Cancel As Boolean) MsgBox "Hello" Application.ScreenUpdating = False Application.EnableEvents = False Sheets("Current Round").Unprotect Password:="xxxxx" Sheets("Current Round Detailed").Unprotect Password:="xxxxx" Sheets("Current Round Graph").Unprotect Password:="xxxxx" Sheets("Home Graphs").Unprotect Password:="xxxxx" Sheets("Home Detailed Graphs").Unprotect Password:="xxxxx" Sheets("All Rounds").Unprotect Password:="xxxxx" Sheets("View Rounds").Unprotect Password:="xxxxx" Sheets("Current Round").Visible = True Sheets("Current Round Detailed").Visible = True Sheets("Current Round Graph").Visible = True Sheets("Home Graphs").Visible = True Sheets("Home Detailed Graphs").Visible = True Sheets("All Rounds").Visible = True Sheets("View Rounds").Visible = True 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("LogGraph3").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 .CommandBars("Worksheet Menu Bar").Enabled = True .CommandBars("Standard").Visible = True .CommandBars("Formatting").Visible = True .CommandBars("Drawing").Visible = 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", "LogGraph3")) Wksht.Activate ActiveWindow.DisplayHeadings = True Next Application.ScreenUpdating = True Application.EnableEvents = True End Sub Thanks Sandy |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Workbook_BeforeClose | Excel Programming | |||
Workbook_BeforeClose | Excel Programming | |||
workbook_beforeClose | Excel Programming | |||
Workbook_BeforeClose | Excel Programming | |||
Workbook_BeforeClose | Excel Programming |