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

Announcements

No record found.

News and Announcements icon
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#2
Henrik Nordlöf Profile Picture

Henrik Nordlöf 2 User Group Leader

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans