Set up another macro called "SaveFile". In this macro set a boolean
variable called bByPass to True. Then have the SaveFile macro save your file
Then in the before save code, check and see if this variable is true. If
true, then the code in the before save is bypasseed. Then at the end of the
SaveFile macro, setbByPass back to false.
Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on
VB macros for Excel
"Shilps" wrote in message
...
Hi,
I have a very tricky situation. I want to disble the save option of the
workbook. So I wrote this code
Private Sub Workbook_BeforeClose(Cancel as Boolean)
Application.DisplayAlerts = False
ThisWorkbook.Saved = True
ThisWorkbook.Close
Application.DisplayAlerts = true
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel as Boolean)
Application.DisplayAlerts = False
Cancel = True
Application.DisplayAlerts = true
End Sub
Now the problem is the moment I write this code, it is activated before
saving and this code is not saved at all. How do I save this code? My
objective is that the user should not be able to save any changes in the
workbook.
TIA
Shilps