View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
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