Disable save and close

daffy

Board Regular
Joined
Mar 18, 2009
Messages
113
Hi Guys

I am using the code below but when the message box comes up i would like it to close the file when the user clicks ok. I think i need to add the line "Me.Close"
but i am not sure where to put it. Or do i need to put another other line some where else?

Thanks for your help in advanced.




Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
MsgBox "Did you really think i would allow you to steal my work and call it your own? DO YOUR OWN WORK"

Cancel = True

If SaveAsUI Then SaveAsUI = False
End Sub
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
addition in bold face red. of course this will only work if the user enables macros.


Rich (BB code):
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
MsgBox "Did you really think i would allow you to steal my work and call it your own? DO YOUR OWN WORK"
 
Cancel = True
 
If SaveAsUI Then SaveAsUI = False

ThisWorkbook.Close SaveChanges:=False

End Sub
 
Upvote 0

Forum statistics

Threads
1,213,544
Messages
6,114,249
Members
448,556
Latest member
peterhess2002

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