Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Problem with scheduler

Using Windows 98 and Office 2000.

I have a file containing an Excel Macro which starts and runs successfully
whenever the file is opened. But if I run it from Windows Scheduler when
Excel is already open it opens a second copy of Excel which creates other
problems and then hangs..I see nothing in my program which would cause this,
so maybe it's a feature of Windows Scheduler.

Has anyone run into this problem and can you give me some pointers on how to
fix it.

Thanks,

Jim


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Problem with scheduler

Seems to me that this is normal behaviour of the Window task scheduler.
This is one way of doing this:


First let the scheduler open a Word document with the following code in the
document open event:

Private Sub Document_Open()

Dim oXL As Object

On Error Resume Next

'get a reference to the running Excel application
Set oXL = GetObject(, "Excel.Application")

If Err.Number = 0 Then
'close Excel
oXL.Application.Quit
End If

Set oXL = Nothing

'close Word
Application.Quit

End Sub

This will close Excel if it was running and close Word.
Then one minute later you run your real task that runs your Excel code.
There might be a nicer way of doing this via a .bat file or via VBScript,
but
I couldn't figure that out quick enough.


RBS



"jim simpson" wrote in message
news:yleGd.76273$Jk5.61837@lakeread01...
Using Windows 98 and Office 2000.

I have a file containing an Excel Macro which starts and runs successfully
whenever the file is opened. But if I run it from Windows Scheduler when
Excel is already open it opens a second copy of Excel which creates other
problems and then hangs..I see nothing in my program which would cause
this,
so maybe it's a feature of Windows Scheduler.

Has anyone run into this problem and can you give me some pointers on how
to
fix it.

Thanks,

Jim



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Problem with scheduler

Thanks RBS for the help.

If that is the way the Scheduler is suppose to work then I have to close
Excel if it's open. Maybe I can work up a bat file to do it and also start
the scheduled file, that way everything could be in one file.

Thanks,

Jim


"RB Smissaert" wrote in message
...
Seems to me that this is normal behaviour of the Window task scheduler.
This is one way of doing this:


First let the scheduler open a Word document with the following code in

the
document open event:

Private Sub Document_Open()

Dim oXL As Object

On Error Resume Next

'get a reference to the running Excel application
Set oXL = GetObject(, "Excel.Application")

If Err.Number = 0 Then
'close Excel
oXL.Application.Quit
End If

Set oXL = Nothing

'close Word
Application.Quit

End Sub

This will close Excel if it was running and close Word.
Then one minute later you run your real task that runs your Excel code.
There might be a nicer way of doing this via a .bat file or via VBScript,
but
I couldn't figure that out quick enough.


RBS



"jim simpson" wrote in message
news:yleGd.76273$Jk5.61837@lakeread01...
Using Windows 98 and Office 2000.

I have a file containing an Excel Macro which starts and runs

successfully
whenever the file is opened. But if I run it from Windows Scheduler when
Excel is already open it opens a second copy of Excel which creates

other
problems and then hangs..I see nothing in my program which would cause
this,
so maybe it's a feature of Windows Scheduler.

Has anyone run into this problem and can you give me some pointers on

how
to
fix it.

Thanks,

Jim





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Problem with scheduler

Closing an application is not as easy as opening one and I am not sure a
..bat file can do it.
I would think VB Script can do it, but I couldn't see an easy way.
Of course what you could do is open the Word file, let it close Excel and
then let it open
the Excel file with your code. Then let the Excel file close Word.
That way everything would be in one file.

RBS


"jim simpson" wrote in message
news:ZRvGd.77482$Jk5.44137@lakeread01...
Thanks RBS for the help.

If that is the way the Scheduler is suppose to work then I have to close
Excel if it's open. Maybe I can work up a bat file to do it and also start
the scheduled file, that way everything could be in one file.

Thanks,

Jim


"RB Smissaert" wrote in message
...
Seems to me that this is normal behaviour of the Window task scheduler.
This is one way of doing this:


First let the scheduler open a Word document with the following code in

the
document open event:

Private Sub Document_Open()

Dim oXL As Object

On Error Resume Next

'get a reference to the running Excel application
Set oXL = GetObject(, "Excel.Application")

If Err.Number = 0 Then
'close Excel
oXL.Application.Quit
End If

Set oXL = Nothing

'close Word
Application.Quit

End Sub

This will close Excel if it was running and close Word.
Then one minute later you run your real task that runs your Excel code.
There might be a nicer way of doing this via a .bat file or via VBScript,
but
I couldn't figure that out quick enough.


RBS



"jim simpson" wrote in message
news:yleGd.76273$Jk5.61837@lakeread01...
Using Windows 98 and Office 2000.

I have a file containing an Excel Macro which starts and runs

successfully
whenever the file is opened. But if I run it from Windows Scheduler
when
Excel is already open it opens a second copy of Excel which creates

other
problems and then hangs..I see nothing in my program which would cause
this,
so maybe it's a feature of Windows Scheduler.

Has anyone run into this problem and can you give me some pointers on

how
to
fix it.

Thanks,

Jim






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
How to run macro with scheduler Dan Excel Discussion (Misc queries) 4 August 19th 07 04:46 PM
task scheduler Big Jim New Users to Excel 0 June 1st 06 07:00 PM
Scheduler and passwords VPH Excel Discussion (Misc queries) 2 May 19th 06 06:15 PM
Problem running a probram using SQL 2000 Job Scheduler Steven N Excel Programming 2 July 29th 04 10:01 AM
Task Scheduler Rone Excel Programming 1 December 12th 03 06:10 PM


All times are GMT +1. The time now is 12:30 AM.

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

About Us

"It's about Microsoft Excel"