Quantcast
Channel: NetOffice - MS Office in .NET
Viewing all articles
Browse latest Browse all 1741

New Post: Releasing COMObject

$
0
0
Hi,
within my application I'm creating an excel instance, registering a XLL and opening the workbook through a macro within that registered XLL. Afterwards I'm trying to release everything but excel stays in memory. Not loading the file "fileName" closes the excel instance without problems.

My code looks like that:
// start
NetOffice.ExcelApi.Application _excel = new Excel.Application();
_excel.RegisterXLL(xllFullPath);
_excel.Run("MacroThatOpensFile", fileName);
NetOffice.ExcelApi.Workbook excelWorkbook = ExcelApp.Workbooks[System.IO.Path.GetFileName(fileName)];

//release
excelWorkbook.Close(saveChanges: saveReport);
excelWorkbook.Dispose();
excelWorkbook = null;

_excel.Quit();
_excel.Dispose();
_excel = null;
Thanks in advance,
Karsten

Viewing all articles
Browse latest Browse all 1741

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>