JoJoRabbit
New Member
- Joined
- Aug 25, 2020
- Messages
- 2
- Office Version
- 2013
- 2007
- Platform
- Windows
This macro is mainly to hide the sheets of the workbook workbook to only leave behind a splash sheet so that users must enable macros for another macro that unhides necessary sheets and hides the splash sheet on workbook_open.
However, this macro saves the workbook without the usual dialogue box of " save" " dont save" "cancel" appearing which may put off some users, so i'm trying to include a message box that can either save, don't save , or go back to as the user was as if it was a normal save message box, but i am having some issues with this part highlighted in red
code:
However, this macro saves the workbook without the usual dialogue box of " save" " dont save" "cancel" appearing which may put off some users, so i'm trying to include a message box that can either save, don't save , or go back to as the user was as if it was a normal save message box, but i am having some issues with this part highlighted in red
code:
Rich (BB code):
Private Sub Workbook_BeforeClose(Cancel As Boolean)
x = MsgBox("Are you sure you want to quit? clicking 'yes' will save the changes made,clicking 'no' will exit without saving, "cancel" will return you as you were" , vbYesNoCancel)
If x = vbYes Then
ThisWorkbook.Save
ElseIf x = vbNo Then
Activeworkbook.close
ElseIf x = vbCancel Then
"go back to original state
End If
Dim ws As Worksheet
Sheets("START").Visible = xlSheetVisible
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "START" Then
ws.Visible = xlVeryHidden
End If
Next ws
ActiveWorkbook.Save
End Sub
Last edited by a moderator: