Hi all,

I have an excel work book that contains a macro that search the outlook mail for some particular subject and creates a txt file.
In my windows service vb.net program, I would like to open the excel call the macro and close the excel in the OnStart() event.
code:
Code:
Public Class Service1

    Protected Overrides Sub OnStart(ByVal args() As String)
        ' Add code here to start your service. This method should set things
        ' in motion so your service can do its work.
       
        Dim oExcel As Excel.ApplicationClass
        Dim oBook As Excel.WorkbookClass
        Dim oBooks As Excel.Workbooks

        'Start Excel and open the workbook.
        oExcel = CreateObject("Excel.Application")
        oExcel.Visible = True
        oBooks = oExcel.Workbooks
        oBook = oBooks.Open("C:\CAD Audit\make_job_v3.xlsm")
        'oBook.Sheets("Feuil1").select()
        'Run the macros.
        oExcel.Run("test_lecture_mail")

        'Clean-up: Close the workbook and quit Excel.
        oBook.Close(False)
        System.Runtime.InteropServices.Marshal.ReleaseComObject(oBook)
        oBook = Nothing
        System.Runtime.InteropServices.Marshal.ReleaseComObject(oBooks)
        oBooks = Nothing
        oExcel.Quit()
        System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
        oExcel = Nothing

    End Sub

    Protected Overrides Sub OnStop()
        ' Add code here to perform any tear-down necessary to stop your service.
          End Sub
I have the above code, but I dont see the excel macro running and no txt file created.

Any help/suggestions will be very much helpful.
Thanks in advance.