Workbook BeforeSave

B

Barb Reinhardt

Is there some way to prevent saving under certain conditions int he
workbook_before save method?
Thanks,

Barb Reinhardt
 
C

Chip Pearson

Barb,

Put the tests in the BeforeSave event in ThisWorkbook and if the tests
indicate that the Save should be prevented, set the Cancel parameter
that is passed into BeforeSave to True.

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]
 
J

John

What are the conditions? Can you test for them with and IF statement? or put
an if statement in a cell value and test if that cell has a value in the code?
 
R

Ryan H

Yeah that is possible. But I'm not sure what conditions you are wanting to
test so I assumed one. Put this in the before save event. Hope this helps!
If so, let me know, click "YES" below.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

If Sheets("Sheet1").Range("A1").Value = "Don't Save" Then
Cancel = True
End If

End Sub
 
B

Barb Reinhardt

I figured it out. I forgot to include CANCEL = TRUE when I didn't want to
save.

Thanks,

Barb Reinhardt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top