Disabling the "want to save your changes?" dialogue box when closing out of Excel

ktielens

New Member
Joined
Oct 26, 2015
Messages
23
I have a workbook that is stored as read only on a SharePoint site. Users are unable to save the document (save as is allowed), but when closing out of the document, the dialogue box still shows saying "Want to save your changes to [file name]" with options of "save" "don't save" and "cancel".

Is there a way to disable this box from appearing? It only serves to confuse the users. Upon closing I would like the document to close without any kind of save or notification regarding saving.

Thank you in advance.
 
Something like
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

With ThisWorkbook


    If .Path = "C:\My Folder Path" And .Name = "My Workbook Name.xlsm" Then
        .Saved = True
    End If


End With


End Sub
should do. Just replace the Path & FileName with the actual path and file name and you should be covered. Remember that VBA is case sensitive: UCase() or LCase() functions can be used to turn everything upper or lower case.
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Something like
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

With ThisWorkbook


    If .Path = "C:\My Folder Path" And .Name = "My Workbook Name.xlsm" Then
        .Saved = True
    End If


End With


End Sub
should do. Just replace the Path & FileName with the actual path and file name and you should be covered. Remember that VBA is case sensitive: UCase() or LCase() functions can be used to turn everything upper or lower case.

Ok thanks. I will need to do some more research on that, as the document is stored on a SharePoint site.
 
Upvote 0
Something like
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

With ThisWorkbook


    If .Path = "C:\My Folder Path" And .Name = "My Workbook Name.xlsm" Then
        .Saved = True
    End If


End With


End Sub
should do. Just replace the Path & FileName with the actual path and file name and you should be covered. Remember that VBA is case sensitive: UCase() or LCase() functions can be used to turn everything upper or lower case.


Actually, I do not want them to be able to perform a save as, so maybe I will look into that first!
 
Upvote 0

Forum statistics

Threads
1,215,518
Messages
6,125,292
Members
449,218
Latest member
Excel Master

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