Scheduled Task does not instantiate Excel

MnMoondog
03-20-2003, 09:05 AM
I have some VB 6.0 code that looks through an Access 97 database and exports various records to an Excel 97 spreadsheet. The code I use for opening the Excel is as follows:


Set xlApp = New Excel.Application
'---
'Open Excel
'---
Set xlApp = CreateObject("Excel.Application")
xlApp.Workbooks.Add
Set xlsSheet = xlApp.ActiveWorkbook.Sheets(1)
xlApp.Visible = False

When I run the code from the server (logged into the server) the code works great. However, when I schedule the task to run at night the code breaks at the Set xlApp = New Excel.Application line.

I set the security on the Scheduled task to run as the same user that works when I am logged into the system.

I'm at a loss...Please help.

Wamphyri
03-20-2003, 09:45 AM
What error message is it giving?

MnMoondog
03-20-2003, 10:08 AM
In the VB code I have

On Error GoTo ProcessAeroOrders_Error

The error handler is as follows:

ProcessAeroOrders_Error:
On Error Resume Next
gDebug ("Error in clsAccessDB.ProcessAeroOrders: " & Err.Number & " - " & Err.Description)
GoTo ProcessAeroOrders_Exit

gDebug is a routine that writes the error to a log file. The log file has the following entry:

Date: Error in clsAccessDB.ProcessAeroOrders: 0 -

So the Err.Number is 0. Go figure???

icjackson
03-21-2003, 05:33 AM
You may be executing code in your error handler when there is no error (ie Err.Number = 0). Does your code contain an Exit Sub before the error handler starts?

MnMoondog
03-21-2003, 11:22 AM
Yes, I have an Exit Sub Statement before the Error Handler label.

lebb
03-22-2003, 06:50 PM
I don't understand why you have the first line of code there anyway? CreateObject already opens a new instance of Excel. You should be able to just remove the Set xlApp = New Excel.Application line.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum