I cannot seem to end a Microsoft Excel process. I create the Application, Workbook and Worksheet in that order. I load the worksheet data and save the workbook. I make the application visibile and pass usercontrol to it, then close (set to nothing) the Worksheet, Workbook and Application in that order. I figured that would "free up" VB of the objects. When I close the Excel application, the Excel.exe process does not end. The Task Manager shows a seperate process still running for each time I run the VB app.
Why doesn't the Excel process end?
My code is below.
Sub SaveAsExcel()
Dim FileName As String = cboFileName.Text
Dim FileExtension As String = ".xls"
xlApp = CType(CreateObject("Excel.Application"), Microsoft.Office.Interop.Excel.Application)
xlBook = CType(xlApp.Workbooks.Add, Microsoft.Office.Interop.Excel.Workbook)
xlSheet = CType(xlBook.Worksheets(1), Microsoft.Office.Interop.Excel.Worksheet)
LoadWorksheet()
xlBook.SaveAs("C:\" & FileName & FileExtension)
xlApp.Visible = True
xlApp.UserControl = True
xlSheet = Nothing
xlBook = Nothing
xlApp = Nothing
'xlApp.Quit()
End Sub
Why doesn't the Excel process end?
My code is below.
Sub SaveAsExcel()
Dim FileName As String = cboFileName.Text
Dim FileExtension As String = ".xls"
xlApp = CType(CreateObject("Excel.Application"), Microsoft.Office.Interop.Excel.Application)
xlBook = CType(xlApp.Workbooks.Add, Microsoft.Office.Interop.Excel.Workbook)
xlSheet = CType(xlBook.Worksheets(1), Microsoft.Office.Interop.Excel.Worksheet)
LoadWorksheet()
xlBook.SaveAs("C:\" & FileName & FileExtension)
xlApp.Visible = True
xlApp.UserControl = True
xlSheet = Nothing
xlBook = Nothing
xlApp = Nothing
'xlApp.Quit()
End Sub