Save dialog boxes (doubled)

sassriverrat

Well-known Member
Joined
Oct 4, 2018
Messages
655
hello-

I have a button that saves the workbook (code below). Irregardless if I save the workbook using the button (which works), when I go to close the program, it still asks me if I want to save (excel generated, not me). How can I get it so I don't have to save twice. I'd like it so that if I hit the save button, it saves and I can close without issues. If I hit close without having the second box come up.

Side note- I just typed that last piece up- maybe somebody knows how it's supposed to be written (assuming I'm wrong). It's so that the program won't be closed if other workbooks are opened, just this one.

Thanks!

Edit- Could this be from the last piece of code?

Code:
Private Sub DailySaver()ActiveSheet.EnableCalculation = False
ActiveWorkbook.Save
'If Workbooks.Open > 1 Then
    'Application.Quit
    'Else: ActiveWorkbook.Quit
    'End If
End Sub

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'This is the last event to run as Excel is closing


Sheets("Notes").Visible = xlVeryHidden
Sheets("Developer").Visible = xlVeryHidden




End Sub
 
Last edited:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
In the BeforeClose event handler, you're making changes to your workbook. You're changing the Visible property for your two sheets. As such, the Saved property of the workbook gets set to False, and hence you'll get that save prompt. You can avoid this by adding another line that saves the workbook after setting the Visible property for your two sheets.
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,399
Members
448,958
Latest member
Hat4Life

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