I have a BeforeClose event in a workbook, however if the user closes the workbook when it is not the active workbook, e.g. from the taskbar, the script executes on the wrong workbook.
Is there a way to tell which workbook triggered the event and reference that workbook rather than ActiveWorkbook?
Private Sub Workbook_BeforeClose(Cancel As Boolean)
' Replaces default Save message box with custom one
' that includes request stats, waings, and errors.
If Not ActiveWorkbook.Saved Then
UF_Stats.Show
If Not GlobalVariables.bAllowClose Then Cancel = True
End If
End Sub
