WorkbookBeforeSave different actions on exit

T

Tom Med

I have an overloaded WorkbookBeforeSave method. When I exit this
procedure I would expect it to run the standard saving functionality.
( Unless I set the Cancel or SaveAs booleans) However it seems to
have different results based on if anything is done in the function or
not.

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:=InstallDir & "NewFile.xls"
Application.DisplayAlerts = True

If the function isDeveloper returns false the below overloaded
procedure does not save the file on its exit

Private Sub App_WorkbookBeforeSave(ByVal WB As Workbook, ByVal
SaveAsUI As Boolean, Cancel As Boolean)

If Not isDeveloper Then Exit Sub

....

End sub

However if I create temp variable the excel will now save the file
successfully

Private Sub App_WorkbookBeforeSave(ByVal WB As Workbook, ByVal
SaveAsUI As Boolean, Cancel As Boolean)

Dim tempvar As Integer
tempvar = 1

If Not isDeveloper Then Exit Sub

....

End sub

Is there some rational for why this happens? Are there any caveat's
for event overloading that I am missing out on?

Thanks
Tom
 

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