save conunderum

T

ted daniels

how can i put

cancel = true

in the

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

section of the source code

when ever i do, it won't save the changes. I searched in
the old records and found a reference to
www.cpearson.com/excel/vbe.htm
but this is either too complicated for a 'newbie' like me
or it won't work. If any one can help, please do. I'm
tearing what little hair i do have, out.
 
F

Frank Kabel

Hi
what are you trying to achieve?
Some workarounds:
After inserting this line in your code type the following
in the Immediate window:
application.enebleevents=false
now save the workbook

after this enter the following in the immediate window
application.enebleevents=True
 
M

Melanie Breden

Hi,

ted said:
how can i put

cancel = true

in the

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

section of the source code

when ever i do, it won't save the changes. I searched in
the old records and found a reference to
www.cpearson.com/excel/vbe.htm
but this is either too complicated for a 'newbie' like me
or it won't work. If any one can help, please do. I'm
tearing what little hair i do have, out.

for example:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
If SaveAsUI Then
MsgBox "User want to 'Save as' the File"
' only 'Save as' will be canceled
Cancel = True
Else
MsgBox "User want to 'save' the file"
' only 'Save' will be canceled
Cancel = True
End If

'Save' and 'Save as' will be canceled
Cancel = True
End Sub


--
Regards
Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)
 
T

Toby Erkson

Spelling error, change to:
application.enableevents=false

This is language specific to Weevils and won't work in the English version:
application.enebleevents=false
Toby Erkson
Oregon, USA
 
Top