R
Rfuu
I am having trouble getting a proccess to run unattended using Excel 2003 on
Windows Server 2008. When I run the code through Visual Studio or run the
..exe through either windows explorere or the cmd prompt it works exactly as
intended but when I try to run it as a windows scheduled task or SQL job the
workbook.open line fails with error code hresult: 0x800a03ec. The code below
is a scaled down version cut from the rest of the proccess but behaves the
same way.
Imports Microsoft.Office.Interop.Excel
Module Module1
Private excelApplication As Application = Nothing
Sub Main()
Dim sFileSpec As String
sFileSpec = "E:\Temp\test.xls"
EventLog.WriteEntry("OpenFileTest", "before try")
Try
excelApplication = New Application
EventLog.WriteEntry("OpenFileTest", "before open " & sFileSpec)
excelApplication.Workbooks.Open(sFileSpec)
EventLog.WriteEntry("OpenFileTest", "before close")
excelApplication.Quit()
Catch ex As Exception
EventLog.WriteEntry("OpenExcelFile Error", ex.ToString)
Finally
If Not excelApplication Is Nothing Then
excelApplication.Quit()
excelApplication = Nothing
End If
End Try
End Sub
End Module
Windows Server 2008. When I run the code through Visual Studio or run the
..exe through either windows explorere or the cmd prompt it works exactly as
intended but when I try to run it as a windows scheduled task or SQL job the
workbook.open line fails with error code hresult: 0x800a03ec. The code below
is a scaled down version cut from the rest of the proccess but behaves the
same way.
Imports Microsoft.Office.Interop.Excel
Module Module1
Private excelApplication As Application = Nothing
Sub Main()
Dim sFileSpec As String
sFileSpec = "E:\Temp\test.xls"
EventLog.WriteEntry("OpenFileTest", "before try")
Try
excelApplication = New Application
EventLog.WriteEntry("OpenFileTest", "before open " & sFileSpec)
excelApplication.Workbooks.Open(sFileSpec)
EventLog.WriteEntry("OpenFileTest", "before close")
excelApplication.Quit()
Catch ex As Exception
EventLog.WriteEntry("OpenExcelFile Error", ex.ToString)
Finally
If Not excelApplication Is Nothing Then
excelApplication.Quit()
excelApplication = Nothing
End If
End Try
End Sub
End Module