Timer

  • Thread starter Thread starter Phil
  • Start date Start date
P

Phil

I have a timer which is calls a function after 5 seconds
(using StartTimer and KillTimer). What I am trying to do
once the timer is activated is to open another file (works
OK) and then close the orginal file that contained the
timer functions. The problem is that all of excel shuts
down, including the newly opened spreadsheet. The code for
closing files works as I use it often. Also, the Auto_Open
() fails to run when I open the second excel file.

Any thoughts?

thanks
 
Phil,

Does StartTimer and KillTimer use CallBack code by any chance?

Auto_Open will not run for a file opened in VBA, you either need to run it
explicitly, or use Workbook_Open event.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Hi Phil,
"and then close the orginal file that contained the
timer functions."

If you close the workbook containing the code, the code stops running!


--
John
johnf 202 at hotmail dot com


| I have a timer which is calls a function after 5 seconds
| (using StartTimer and KillTimer). What I am trying to do
| once the timer is activated is to open another file (works
| OK) and then close the orginal file that contained the
| timer functions. The problem is that all of excel shuts
| down, including the newly opened spreadsheet. The code for
| closing files works as I use it often. Also, the Auto_Open
| () fails to run when I open the second excel file.
|
| Any thoughts?
|
| thanks
 
Hi Phil,
I have a timer which is calls a function after 5 seconds
(using StartTimer and KillTimer). What I am trying to do
once the timer is activated is to open another file (works
OK) and then close the orginal file that contained the
timer functions. The problem is that all of excel shuts
down, including the newly opened spreadsheet. The code for
closing files works as I use it often. Also, the Auto_Open
() fails to run when I open the second excel file.

Is there a reason you're using StartTimer and KillTimer (i.e. API-level
calls) instead of Application.OnTime (i.e. application-level calls)?

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.co.uk
 
The crash *may* be because the callback routine has disappeared when
you closed the original workbook. Do you call KillTimer before closing
the original workbook? If so, is it working?

Also, it's a design intent that Auto_ procedures do not run when a
workbook is opened programmatically. Either invoke the procedure
explicitly or use a Workbook_Open procedure.

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
Back
Top