ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   WorkBook Deactivate Event (https://www.excelbanter.com/excel-programming/434639-workbook-deactivate-event.html)

faffo1980

WorkBook Deactivate Event
 
Hi all,
The workbook Deactivate event is called when the active workbook is changed
and when the workbook is closed.
The event BeforeClosed for a workbook is called before the event Deactivate.

Is there a way to determine if the WB deactivation is caused by a Close
operation or a change operation?

Thanks

faffo1980

Jacob Skaria

WorkBook Deactivate Event
 
Copy the below code in 'This Workbook' and try...

Dim blnClose As Boolean
Private Sub Workbook_BeforeClose(Cancel As Boolean)
blnClose = True
End Sub

Private Sub Workbook_Deactivate()
If blnClose Then
MsgBox "Close_Deactivate"
Else
MsgBox "Deactivate"
End If
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"faffo1980" wrote:

Hi all,
The workbook Deactivate event is called when the active workbook is changed
and when the workbook is closed.
The event BeforeClosed for a workbook is called before the event Deactivate.

Is there a way to determine if the WB deactivation is caused by a Close
operation or a change operation?

Thanks

faffo1980


Patrick Molloy[_2_]

WorkBook Deactivate Event
 
in the code page for ThisWorkbook

Option Explicit
Private closeflag As Boolean
Private Sub Workbook_BeforeClose(Cancel As Boolean)
closeflag = True
End Sub
Private Sub Workbook_Deactivate()
If closeflag Then
MsgBox "Closed"
Else
MsgBox "changed"
End If
End Sub


"faffo1980" wrote:

Hi all,
The workbook Deactivate event is called when the active workbook is changed
and when the workbook is closed.
The event BeforeClosed for a workbook is called before the event Deactivate.

Is there a way to determine if the WB deactivation is caused by a Close
operation or a change operation?

Thanks

faffo1980



All times are GMT +1. The time now is 12:51 PM.

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