Hallo,
in meinem Programm greife ich auf Excel zu um dort Daten zu speichern. Mein Problemm, wenn ich den nachfolgendem Code verwende um eine Exel Dateu zu erstellen und zu beenden, wird das Programm Excel lt. Task-Manager nicht geschlossen.
Wie kann ich Excel wirklich beenden?
Gruß, Rudi
in meinem Programm greife ich auf Excel zu um dort Daten zu speichern. Mein Problemm, wenn ich den nachfolgendem Code verwende um eine Exel Dateu zu erstellen und zu beenden, wird das Programm Excel lt. Task-Manager nicht geschlossen.
Wie kann ich Excel wirklich beenden?
Quellcode
- Public Class Form1Private
- Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- 'Sub TestExcel()Dim xlApp As Microsoft.Office.Interop.Excel.Application
- Dim xlBook As Microsoft.Office.Interop.Excel.WorkbookDim xlSheet As Microsoft.Office.Interop.Excel.WorksheetxlApp = 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)
- ' The following statement puts text in the second row of the sheet.
- xlSheet.Cells(2, 2) = "This is column B row 2"
- ' The following statement shows the sheet.
- xlSheet.Application.Visible = True
- ' The following statement saves the sheet to the C:\Test.xls directory.xlSheet.SaveAs("C:\Test.xls")
- xlApp.Quit()End Sub
- End Class
Gruß, Rudi