ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   App_WorkBookBeforeClose() (https://www.excelbanter.com/excel-programming/388382-app_workbookbeforeclose.html)

[email protected]

App_WorkBookBeforeClose()
 
Hi ,

I have a piece of VBA code , it goes like this , the class module has
Public WithEvents app As Application

Private Sub App_WorkbookBeforeClose(ByVal Wb As Workbook, _
Cancel As Boolean)
a = MsgBox("Do you really want to close the workbook?", _
vbYesNo)
If a = vbNo Then Cancel = True
End Sub
for WorkBookBeforeClose under app tab

and another module has

Public oappobject As New Class1
Sub auto_open()
Set oappobject.app = Application

End Sub

for auto_open under General tab in VBA

I saved this as Test.xla , and put under XLSTART folder .
When excel is run , my message appears twice for Excel 2003 and once
for Excel 2000. Can somebody explain the behaviour and suggest a
workaround for this .

Thanks in anticipation,
Deepa


Bob Phillips

App_WorkBookBeforeClose()
 
Deepa,

I have just re-created your situation, and I only get the one message in
Excel 2003.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



wrote in message
oups.com...
Hi ,

I have a piece of VBA code , it goes like this , the class module has
Public WithEvents app As Application

Private Sub App_WorkbookBeforeClose(ByVal Wb As Workbook, _
Cancel As Boolean)
a = MsgBox("Do you really want to close the workbook?", _
vbYesNo)
If a = vbNo Then Cancel = True
End Sub
for WorkBookBeforeClose under app tab

and another module has

Public oappobject As New Class1
Sub auto_open()
Set oappobject.app = Application

End Sub

for auto_open under General tab in VBA

I saved this as Test.xla , and put under XLSTART folder .
When excel is run , my message appears twice for Excel 2003 and once
for Excel 2000. Can somebody explain the behaviour and suggest a
workaround for this .

Thanks in anticipation,
Deepa





All times are GMT +1. The time now is 03:01 AM.

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