ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   killing an OnTime schedule launched from a different workbook (https://www.excelbanter.com/excel-discussion-misc-queries/93054-killing-ontime-schedule-launched-different-workbook.html)

Antonio

killing an OnTime schedule launched from a different workbook
 
client1 portfolio.xls workbook launches every minute the following to update
the max and min of a portfolio value that is updated with real prices. Note
that the time in an exact minute so that it is easy to know the exact time
next scheduled:

Application.OnTime TimeValue(Hour(Now) & ":" & Minute(Now)) +
TimeValue("00:01"), "max_min"

Within the same workbook I have

Public Sub kill_max_min()

Application.OnTime TimeValue(Hour(Now) & ":" & Minute(Now)) +
TimeValue("00:01"), "max_min", , False

End Sub

That kills the OnTime when needed, for example, Before_Close. Killing the
OnTime schedule is needed because otherwise the workbook opens up after
closing (Is there an easier way to avoid the automatic reopening?). It works
fine when within the same workbook.

However, a different project in a different workbook needs to close the
workbook above. Before closing, ( since the Before_Close module is not run
when closing programmatically), I need to kill the max_min scheduled. I am
using

Application.Run "'" & client(client_index) & " portfolio.xls" &
"'!kill_max_min"


It does run the kill_max_min but it gives error. Run time error 1004. Method
On Tie of object_ Application failed.

It looks like it has lost the addressing to max_min

How can it be solved? Am I complicating this unnecessarily?

Thanks,

Antonio


Dave Peterson

killing an OnTime schedule launched from a different workbook
 
Why do you say that the workbook_beforeclose event doesn't fire when closing
Workbook A from workbook B?

It does for me.

In fact, the only way I know to stop it is to disableevents before I close that
workbook.

If you're doing that, is there a reason?

Antonio wrote:

client1 portfolio.xls workbook launches every minute the following to update
the max and min of a portfolio value that is updated with real prices. Note
that the time in an exact minute so that it is easy to know the exact time
next scheduled:

Application.OnTime TimeValue(Hour(Now) & ":" & Minute(Now)) +
TimeValue("00:01"), "max_min"

Within the same workbook I have

Public Sub kill_max_min()

Application.OnTime TimeValue(Hour(Now) & ":" & Minute(Now)) +
TimeValue("00:01"), "max_min", , False

End Sub

That kills the OnTime when needed, for example, Before_Close. Killing the
OnTime schedule is needed because otherwise the workbook opens up after
closing (Is there an easier way to avoid the automatic reopening?). It works
fine when within the same workbook.

However, a different project in a different workbook needs to close the
workbook above. Before closing, ( since the Before_Close module is not run
when closing programmatically), I need to kill the max_min scheduled. I am
using

Application.Run "'" & client(client_index) & " portfolio.xls" &
"'!kill_max_min"

It does run the kill_max_min but it gives error. Run time error 1004. Method
On Tie of object_ Application failed.

It looks like it has lost the addressing to max_min

How can it be solved? Am I complicating this unnecessarily?

Thanks,

Antonio


--

Dave Peterson

Antonio

killing an OnTime schedule launched from a different workbook
 
Hi Dave,

Yes, you are right. Ithe workbook_beforeclose event is fired when closing
from a different workbook.



It is just, that, as you can see from my other post. The ontime does not
seem to be cancelled when run from the beforeclose.



I am not disabling events.

"Dave Peterson" wrote:

Why do you say that the workbook_beforeclose event doesn't fire when closing
Workbook A from workbook B?

It does for me.

In fact, the only way I know to stop it is to disableevents before I close that
workbook.

If you're doing that, is there a reason?

Antonio wrote:

client1 portfolio.xls workbook launches every minute the following to update
the max and min of a portfolio value that is updated with real prices. Note
that the time in an exact minute so that it is easy to know the exact time
next scheduled:

Application.OnTime TimeValue(Hour(Now) & ":" & Minute(Now)) +
TimeValue("00:01"), "max_min"

Within the same workbook I have

Public Sub kill_max_min()

Application.OnTime TimeValue(Hour(Now) & ":" & Minute(Now)) +
TimeValue("00:01"), "max_min", , False

End Sub

That kills the OnTime when needed, for example, Before_Close. Killing the
OnTime schedule is needed because otherwise the workbook opens up after
closing (Is there an easier way to avoid the automatic reopening?). It works
fine when within the same workbook.

However, a different project in a different workbook needs to close the
workbook above. Before closing, ( since the Before_Close module is not run
when closing programmatically), I need to kill the max_min scheduled. I am
using

Application.Run "'" & client(client_index) & " portfolio.xls" &
"'!kill_max_min"

It does run the kill_max_min but it gives error. Run time error 1004. Method
On Tie of object_ Application failed.

It looks like it has lost the addressing to max_min

How can it be solved? Am I complicating this unnecessarily?

Thanks,

Antonio


--

Dave Peterson



All times are GMT +1. The time now is 03:31 PM.

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