View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Vergel Adriano Vergel Adriano is offline
external usenet poster
 
Posts: 857
Default Unhiding worksheets if Close is Canceled

Hi Tanya,

Maybe something like this:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If vbNo = MsgBox("Close this workbook?", vbYesNo) Then
Cancel = True
Else
'Put the code here that hides everything except Sheet1
End If
End Sub



--
Hope that helps.

Vergel Adriano


"JustBreathe" wrote:

I've put in the coding that has been suggested to others as the work-around
for not being able to enable macros with a macro.

It hides all the worksheets (except for 'Sheet1' which contains the message
to that the workbook need to be opened with macros enabled ) before closing.
When the workbook is opened with macos enabled, code will unhide those hidden
sheets and hid 'Sheet1'.

This works, except that I have realized that if 'Cancel' is selected when
closing, it leaves the 'Sheet1' reminder sheet visible and the working tabs
hidden. Is there a way to code the beforeclose section so that the worksheet
will revert back to 'sheet1 hidden' and all other sheets visible in the event
the user decides not to close but to continue working in the file?

TIA
Tanya (self-teach VBA as i go)