ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Application Level Events (https://www.excelbanter.com/excel-programming/416028-application-level-events.html)

Kent Prokopy

Application Level Events
 
I need a way to have a sub within my xla to run every time any workbook gets
or losses focus. So if a new workbook is opened or closed, or you just switch
back and forth between two workbooks.

Dave Peterson

Application Level Events
 
You can read more about application events at Chip Pearson's site:
http://www.cpearson.com/excel/AppEvent.aspx

FYI: these events fire when you stay within Excel. If you swap applications,
they don't fire.

Kent Prokopy wrote:

I need a way to have a sub within my xla to run every time any workbook gets
or losses focus. So if a new workbook is opened or closed, or you just switch
back and forth between two workbooks.


--

Dave Peterson

JLGWhiz

Application Level Events
 
You can put this in the ThisWorkbook code module. Substitute your macro name
for myMacro.

Private Sub Workbook_Deactivate()
Call myMacro
End Sub

"Kent Prokopy" wrote:

I need a way to have a sub within my xla to run every time any workbook gets
or losses focus. So if a new workbook is opened or closed, or you just switch
back and forth between two workbooks.


Kent Prokopy

Application Level Events
 
I found this information in one of the other posts just before you replied.
This is just what I needed.

Thank you very much!


"Dave Peterson" wrote:

You can read more about application events at Chip Pearson's site:
http://www.cpearson.com/excel/AppEvent.aspx

FYI: these events fire when you stay within Excel. If you swap applications,
they don't fire.

Kent Prokopy wrote:

I need a way to have a sub within my xla to run every time any workbook gets
or losses focus. So if a new workbook is opened or closed, or you just switch
back and forth between two workbooks.


--

Dave Peterson



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

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