Calling the 'save changes' dialogue box

gfinney

New Member
Joined
Apr 7, 2022
Messages
1
Office Version
  1. 2010
Platform
  1. Windows
Hi there,

In the below section of code I'd like to call the 'save changes' dialogue so the user is asked 'do you want to save changes' before the code hides workseets and shows the welcome sheet - After searching all I can find is the Application.GetSaveAsFilename but I don't want to save as a new file or to automatically save/not save just in case

This is so that it doesn't confuse users who are using the sheet properly because as it is the welcome sheet pops up behind the save changes dialogue box when they close but haven't saved their changes, the code i'm using is simply to run a timer to close the workbook after 5 mins of inactivity and there's a hide all sheets except the welcome sheet so that if they don't enable content and let the timer run they cant access the data ie if you don;t enable content all you see is a welcome sheet that says 'please click enable content' with all other sheets hidden

Grateful of any help thank you.

VBA Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Call StopTimer
'call do you want to save changes dialogue box if there are unsaved changes
    Application.ScreenUpdating = False
    Sheets("Welcome").Visible = xlSheetVisible
    For Each Sh In Worksheets
If Not Sh.Name = "Welcome" Then Sh.Visible = xlVeryHidden
Next Sh
End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
It would be simpler to just pop up a message box of your own using MsgBox
 
Upvote 0

Forum statistics

Threads
1,215,022
Messages
6,122,716
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top