close

I am using the Task Scheduler to open an Excel file at timed intervals. The
problem is the Task Scheduler always opens a new session of Excel even when
Excel is already running. Is there any way to get the Task Scheduler to use
the current session of Excel to open the file if Excel is already running?
Thanks in advance.

Yes. Consider using the OnTime method within Excel to do the scheduling
rather than task manager.

Another option is if you are running a macro each time Task Manager starts
Excel, then have the macro close the application when it is done.
--
Gary's Studentquot;Carlquot; wrote:

gt; I am using the Task Scheduler to open an Excel file at timed intervals. The
gt; problem is the Task Scheduler always opens a new session of Excel even when
gt; Excel is already running. Is there any way to get the Task Scheduler to use
gt; the current session of Excel to open the file if Excel is already running?
gt; Thanks in advance.

The first thing I'd try...

Sometimes one of these works when you're having trouble with double clicking on
the file in windows explorer:

Tools|Options|General|Ignore other applications (uncheck it)

--- or ---

Close Excel and
Windows Start Button|Run
excel /unregserver
then
Windows Start Button|Run
excel /regserver

The /unregserver amp; /regserver stuff resets the windows registry to excel's
factory defaults.

If neither of them worked, then I think I'd use the task scheduler to start a
..vbs script that does what I want. It could find an already running instance of
excel or start a new one if excel isn't running.

Something like this:
'------------------
dim myXL
dim myWkbk
Dim XLWasRunning

xlwasrunning = true
On Error Resume Next
Set myXL = GetObject(, quot;Excel.Applicationquot;)
If Err.Number = 429 Then
set myXL = createobject(quot;excel.applicationquot;)
xlwasrunning = false
end If
on error goto 0

myxl.visible = true 'nice for testing

set mywkbk = myxl.workbooks.open(quot;C:\my documents\excel\book1.xlsquot;)
mywkbk.worksheets(1).range(quot;a1quot;).value = quot;Changed from VBSquot;
mywkbk.close true 'or false to not save changes

if xlwasrunning = false then
myxl.quit
end if

set mywkbk = nothing
Set myxl = nothing

'-------------------

Save it as a NiceName.VBS
Carl wrote:
gt;
gt; I am using the Task Scheduler to open an Excel file at timed intervals. The
gt; problem is the Task Scheduler always opens a new session of Excel even when
gt; Excel is already running. Is there any way to get the Task Scheduler to use
gt; the current session of Excel to open the file if Excel is already running?
gt; Thanks in advance.

--

Dave Peterson

全站熱搜
創作者介紹
創作者 software 的頭像
software

software

software 發表在 痞客邦 留言(0) 人氣()