An 'event' of zero activity?

D

don bowyer

I have 2 workbooks Wb1 & Wb2 open
I have code which does something under the WindowActivate
event in the ThisWorkbook Object for each Wb.
If I am displaying Wb1 and use Window on the main workbook
menu to switch to
Wb2, then the WindowActivate event is triggered for Wb2,
as expected, and my code
runs.
If I then use File, Close on main workbook menu to close
Wb2, the WindowActivate
event is triggered for Wb1 and my code runs.
Now the rub. I have code options which close the active
Wb:-
Workbooks("Filename.xls").Close savechanges:=False
Workbooks("Filename.xls").Close savechanges:=True
If I use either of these to close Wb1 both do as required,
BUT do not trigger the WindowActivate for Wb2.
Maybe that's how Excel VBA works, but I do need a trigger
for Wb(x)
when I use my code to close Wb(y)
Am looking for something that don't exist?
Any help would be much appreciated.
Don Bowyer
 
C

Chip Pearson

Don,

The Activate of the second workbook does fire when the first
workbook is closed (and vice versa). I suspect you have
something else going on in the logic of your code. By chance,
are you setting EnableEvents to False anywhere?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
G

Guest

Thanks for the reply Chip.
I haven't set EnableEvents to False.
Maybe there is something else going on in my code. I'll
look at that, but don't see what it can be if the Activate
event SHOULD be happening.
Don Bowyer
 
G

Guest

Hi Tom - thanks for the reply.
Presumably you mean put some code in Wb1 to activate Wb2
and vice-versa.
Don Bowyer
 
T

Tom Ogilvy

You showed code that closes the workbooks:

Workbooks("Filename.xls").Close savechanges:=False
Workbooks("Filename.xls").Close savechanges:=True

so activate each workbook before closing was my thought. But Chip said the
event should fire, so I would believe him.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top