Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default An 'event' of zero activity?

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default An 'event' of zero activity?

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



"don bowyer" wrote in
message ...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default An 'event' of zero activity?

Why not use code that activates the workbook before closing it.

--
Regards,
Tom Ogilvy


"don bowyer" wrote in message
...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default An 'event' of zero activity?

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
-----Original Message-----
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



"don bowyer" wrote

in
message ...
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



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default An 'event' of zero activity?

Hi Tom - thanks for the reply.
Presumably you mean put some code in Wb1 to activate Wb2
and vice-versa.
Don Bowyer
-----Original Message-----
Why not use code that activates the workbook before

closing it.

--
Regards,
Tom Ogilvy


"don bowyer" wrote

in message
...
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



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default An 'event' of zero activity?

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.

--
Regards,
Tom Ogilvy

wrote in message
...
Hi Tom - thanks for the reply.
Presumably you mean put some code in Wb1 to activate Wb2
and vice-versa.
Don Bowyer
-----Original Message-----
Why not use code that activates the workbook before

closing it.

--
Regards,
Tom Ogilvy


"don bowyer" wrote

in message
...
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



.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
activity Don Guillett[_2_] Excel Worksheet Functions 1 August 5th 11 08:14 PM
Activity Don Guillett[_2_] Excel Worksheet Functions 3 August 4th 11 04:36 PM
Alert if the travel activity is after the work activity Go Bucks!!! Excel Worksheet Functions 3 September 11th 09 05:44 PM
How to find the date of the last activity MSSailor Excel Discussion (Misc queries) 3 March 14th 09 02:07 AM
activity duration -jawad Setting up and Configuration of Excel 1 August 27th 07 01:18 AM


All times are GMT +1. The time now is 07:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"