I have the following routines inThisWorkbook but althougg I can get the auto_open to work I can't get the BeforeClose to work.
Anyone have any ideas?
VB Code:
Option Explicit Private Sub auto_open() For Each ws In ThisWorkbook.Worksheets If Not ws.Name = "Error" Then ws.Visible = xlSheetVisible Else End If Next ws Worksheets("Error").Visible = xlSheetVeryHidden End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.EnableEvents = False MsgBox ("Closing") If Not ThisWorkbook.Saved Then Else Worksheets("Error").Visible = xlSheetVisible For Each ws In ThisWorkbook.Worksheets If Not ws.Name = "Error" Then ws.Visible = xlSheetVeryHidden Else ws.Visible = xlSheetVisible End If Next ws ThisWorkbook.Save End If End Sub
Thanks




Reply With Quote