After Save Event

Magdoulin

Board Regular
Joined
Jan 11, 2013
Messages
73
Hi guys, I hope you are doing well.

Would you please assist with the below.

I’m attaching after save event to close.

However, I want to proceed with an update to ask the code to close the sheet as read-only mode.

What kind of modification I should apply here?


Code:
[COLOR=#252C2F][FONT=Courier]Private Sub Workbook_AfterSave(ByVal Success As Boolean)
[/FONT][/COLOR]If Success Then
ThisWorkbook.Close
End If
End Sub

P.S. this post was originally posted in ozgrid but there was no solution there:
https://www.ozgrid.com/forum/forum/help-forums/excel-vba-macros/1204146-after-save-event
 
Last edited:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
The file will already have saved by the time the AfterSave code runs, so perhaps you need the code to resave it to the same place as read-only recommended?
Code:
With ActiveWorkbook
  .SaveAs(.Path & "/" & .Name,,,,True)
End With
 
Upvote 0
yes, exactly, I need the save to be with read-only
but not resave, just save with read only mode activated
how could I do that?
 
Upvote 0
Sorry for the delay in replying. If the save is to be done by macro, use the code that I provided before in that macro. But that won't stop anyone bypassing it by saving using File>SaveAs or Ctrl+S. The only way you can catch that is putting something in the After Save event which overwrites the save that they have done with a read-only recommended version.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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