ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   WorkbookBeforeSave different actions on exit (https://www.excelbanter.com/excel-programming/399831-workbookbeforesave-different-actions-exit.html)

Tom Med

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



All times are GMT +1. The time now is 05:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com