Can't save Excel Workbook (ASP.NET)

Suslik

New member
Joined
Apr 30, 2004
Messages
1
Hi.

There is my code:

Code:
        Dim XLS As New Excel.Application()
        Dim Wb As Excel.Workbook
        Dim Ws As Excel.Worksheet

        XLS.DisplayAlerts = False
        XLS.Visible = False
        XLS.SheetsInNewWorkbook = 1
        Wb = XLS.Workbooks.Add
        Ws = Wb.Worksheets(1)

.....

        Wb.SaveAs("c:\winnt\temp\file_name.xls")   (!)

        Wb.Close(Excel.XlSaveAction.xlDoNotSaveChanges)
        System.Runtime.InteropServices.Marshal.ReleaseComObject(Ws)
        Ws = Nothing
        System.Runtime.InteropServices.Marshal.ReleaseComObject(Wb)
        Wb = Nothing
        XLS.Quit()
        System.Runtime.InteropServices.Marshal.ReleaseComObject(XLS)
        XLS = Nothing

These code correctly working on my local computer, but generated error in line marked (!) on the server:

[NullReferenceException: Object reference not set to an instance of an object.]
Excel.WorkbookClass.SaveAs(Object Filename, Object FileFormat, Object Password, Object WriteResPassword, Object ReadOnlyRecommended, Object CreateBackup, XlSaveAsAccessMode AccessMode, Object ConflictResolution, Object AddToMru, Object TextCodepage, Object TextVisualLayout, Object Local) +0

Excel 2000 installed both my computer and server. Where is the problem?
 
Back
Top