Excel VBA - Workbook_BeforeSave

Joined
May 22, 2007
Messages
1
Reaction score
0
Hi

I may have missed the posts on here regarding the above. I am trying to write VBA for the

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
function.

It seems to work fine as follows -

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
' aborts the saving process
' start your own saving procedure
Dim varanswer As String
varanswer = MsgBox("Have you updated the report?", vbExclamation, "WARNING")
If varanswer = vbOK Then
ActiveWorkbook.Save
End If
End Sub

When I hit save I get the msgbox I require, but once I hit ok, the msg box appears again! I am unsure now if the workbook is saved or not.

It seems to be in a bit of a loop!

I am very rusty on this!

Thanks
 
Back
Top