web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How can i close Excel with Microsoft.Office.Interop.Excel dll? AX2009 - Bug?!

(0) ShareShare
ReportReport
Posted on by 95

Hi,

i need some help with the Microsoft.Office.Interop.Excel dll.

If i execute my code, a excel process were runnig after closing

e.g.:

-----no excel process running---------

--------execute----------

Microsoft.Office.Interop.Excel.ApplicationClass     application;
;

application = new Microsoft.Office.Interop.Excel.ApplicationClass();

application.set_Visible(true);
application.Quit();
application = null;

------excel process is already running-----------

If i execute the same process with another class it works:

-----no excel process running---------

--------execute----------

SysExcelApplication  xlsApplication;

;
xlsApplication = SysExcelApplication::construct();
xlsApplication.visible(true);
xlsApplication.quit();
xlsApplication = null;

-----no excel process running---------

 

But i need to use the Microsoft.Office.Interop.Excel, because i need a special function which only avaliable in this dll.

I have searched a lot of time to solve this problem, i think it could be an excel or dynamics ax bug?!

Beside I check exactly what MS describe, but i do not get a solution.

http://msdn.microsoft.com/de-de/library/ee317478.aspx

C#:

using Excel = Microsoft.Office.Interop.Excel;
....
Excel.Application excelApp = null;
....
excelApp = new Excel.Application();
.....
excelApp.Quit(); excelApp = null;


Please help me or i despair of this problem.
Thank you!

 

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    you should set Excel.Application , Excel.Workbook and Excel.Worksheet objects set to null.

    check this sample excel program  csharp.net-informations.com/.../csharp-create-excel.htm

    regards

    gever

  • Verified answer
    Okie Profile Picture
    95 on at

    Thank you very much for your feedback.

    Now i find the problem:

    I have used two Microsoft.Office.Interop.Excel.Range objects.

    1. range       = worksheet.get_Range(CLRInterop::getObjectForAnyType("A:A"), CLRInterop::getObjectForAnyType("A:A"));

    2. range     = worksheet.get_Range(strfmt("A%1", cnt), strfmt("EZ%1", cnt));

    The "new" range object on second step not overwrite the first. The first were resume runing. If i set the range object to null, i close only the active (second) object.

    Solution:

    I used two range variables

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans