View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Med Tom Med is offline
external usenet poster
 
Posts: 27
Default WorkbookBeforeSave different actions on exit

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