Help creating macro to block save msgbox

karkas

Board Regular
Joined
Oct 17, 2007
Messages
170
Office Version
  1. 2013
Platform
  1. Windows
Hello all,

I tried doing a search for this, and found some similar threads, but nothing exactly like I need.

I've created a spreadsheet which I allow others at my work to access as a readme only (they can modify data and print, but it only allows "save as"). So, I don't want it asking them when they try to close the workbook if they want to save. I just want it to close.

I guess it needs to be an auto-run when opened so it is transparent to them? I'm a macro/VBA n00b. Please be gentle!

Thanks
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
See if this is what you mean:

1. Remove the "Read Only" status of the file and open it.
2. Right click the Excel icon just to the left of the "File" menu and choose "View Code"
3. Paste the code below into the right hand pane, close the VB window and save the file.
4. Re-apply the "Read Only" status
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    ThisWorkbook.Saved = True
End Sub
 
Last edited:
Upvote 0
Awesome! Thanks so much, that works perfectly!

Now I have just 2 more quick questions....

If I try to use this same macro for a word document do I need to change some of the wording?

Can a similar macro supress my "margins outside printable area" message box when I try to print that word document?

I know this is an excel forum not word, but I assume the coding is the same/similar.

Thanks again
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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