none
Excel task not close after i try to schedule it RRS feed

  • Question

  • Hello everyone i have problem, i got vb.net application when i debug in task menager the EXCEL.EXE are closed after all operations. When i scheduled it the excel.exe is running. What can be a reason of that?Sample of code :

    Imports Excel = Microsoft.Office.Interop.Excel
    Module Main
    
        Public objApp = New Excel.Application
        Public objWb As Excel.Workbooks = objApp.workbooks
        Public objXlApp As Excel.Application = objWb.Application
    
     With objXlApp
    
                    .Workbooks.Open(Filename:=dire& "report1.xls")
    
                    .Application.DisplayAlerts = False
                    .Application.Visible = False
                    .Application.ScreenUpdating = False
    
                   
                    'activate the Sheet
                    .Sheets("arms").Activate()
    ..............
    ............
     End With
    
                
                objXlApp = Nothing

    The server is windows server 2008 r2. I schedule it on my account (i am administrator) the task is added to my login. There are comboboxes checked by me: run whatever user is log in or log out and high privilages.

    Please of help.

    Friday, June 22, 2012 2:47 PM

All replies

  • if you start app with debugging from VS then there is no suprise that VS closes app after you finish debugging. But normally you should call Close on opended workbooks and quit on main application object. You should also call Marshal.ReleaseComObject on each excel object that you get hold of (here, workbook and sheet)
    Saturday, June 23, 2012 4:25 AM
  • I am doing it sorry in previous post i don't mention about close, heres the code i am using:

    Imports Excel = Microsoft.Office.Interop.Excel
    Module Main
    
        Public objApp = New Excel.Application
        Public objWb As Excel.Workbooks = objApp.workbooks
        Public objXlApp As Excel.Application = objWb.Application
    
     With objXlApp
    
                    .Workbooks.Open(Filename:=dire& "report1.xls")
    
                    .Application.DisplayAlerts = False
                    .Application.Visible = False
                    .Application.ScreenUpdating = False
    
                   
                    'activate the Sheet
                    .Sheets("arms").Activate()
    ..............
    ............
    .ActiveWorkbook.Close(SaveChanges:=True)
                        .Quit()
    
     End With
    
                
                objXlApp = Nothing
    			Marshal.FinalReleaseComObject(objXlApp)
    

    How to face that problem? When I am debugging manually it's everythings ok, but after scheduled the excel.exe always is in the task manager.


    • Edited by JimmyJimm Saturday, June 23, 2012 6:55 AM
    Saturday, June 23, 2012 6:42 AM
  • you have to release every object that you manipulate in excel, not just application object. start with smallest possible program (start excel app, open workbook and immediatly close it) and see if it works, then start adding additional code and see when it stops working and try to determine what is not released
    Saturday, June 23, 2012 7:35 AM
  • I understand but why when i am loggen in on the server and manualy debugging program it always close excel.exe in task manager, and if i am not logged in on th server and the program is scheduled (executing on my login with permission when i am logged off) the excel.exe is in task manager? I wonder..
    Saturday, June 23, 2012 7:48 AM
  • how exactly do you schedule your program to automate excel? of course you know that automationof office apps without user interaction is not really a supported scenario?
    Saturday, June 23, 2012 7:55 AM
  • By create application in vb.net (console application) and add it to Windows server scheduler...
    Saturday, June 23, 2012 11:11 AM