|
-
Dec 16th, 2009, 05:19 PM
#1
Thread Starter
Junior Member
Getting the events of other workbooks
How do I refer to an event and create a function for the event of another workbook?
I have a AddInWorkbook.xla that works as a add in and it needs to refer to whatever new workbook that the user opens. I need the new workbook to tell the AddInWorkbook.xla when the new workbook's closing event is dispatched.
So it is possible to do something like this in VBA Excel?
Or otherwise like adding a event listener to it? Possible?
PHP Code:
//inside AddInWorkbook.xla
ActiveWorkbook.addEventListener("Workbook_Close", closeHandler)
function closeHandler(Event e) {
if e.filename == ActiveWorkbook.filename {
//then from here I can carry on...
}
}
-
Dec 17th, 2009, 12:45 AM
#2
Re: Getting the events of other workbooks
create a class and declare it with events
set the class to the excel application
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Dec 17th, 2009, 02:25 AM
#3
Thread Starter
Junior Member
Re: Getting the events of other workbooks
Thanks.
But how do I declare the events and set the class to the application? Are there any examples? Sorry as this is the first time I am doing this.
-
Dec 17th, 2009, 04:29 AM
#4
Re: Getting the events of other workbooks
check in the help file
using events with application object
or
application object events
if you get stuck i can try to help, but it is not real hard once you start
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Dec 18th, 2009, 12:26 AM
#5
Thread Starter
Junior Member
Re: Getting the events of other workbooks
Thanks westconn. I found the page in the help file. I will try and let u know the result. Thank you so much!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|