This project has moved. For the latest updates, please go here.

Application.GetActiveInstances() returns wrong excel instances

Jul 3, 2014 at 12:35 PM

I am currently discovering the netoffice project and I am quite impressed by what you did at the moment.

I have just a little issue about the Application.GetActiveInstances().

Here is the snippet I use (At this time I have one instance that actually is visible on my desktop and on "fake" instance I use for tests):
         Application xl = new Application();
        List<Application> apps = Application.GetActiveInstances().ToList();

        apps.RemoveAll(app => app.Visible == false);

        return apps;
Actually apps contains 2 instances after Application.GetActiveInstances() but my filter on the visible property is not working whereas I have only one visble on my desktop.

Even stranger, the instance created in the code has the same caption as the other instance which is quite disturbing.

Is that a real issue or am I doing something wrong ?

Jul 19, 2014 at 4:36 AM
Edited Jul 19, 2014 at 4:37 AM
its true.

this is because a mistake by microsoft. the COM running object table(ROT) returns always the first instance pointer in memory for any entry, sad but true. i suggest you to study latest source (\Tests\Concept Tests\ObjectFromWindow) to pin point all running applications once and for all !!! the test was made for ms-excel, let me know if you need help to use this concept in a different application. (of course, the NO 1.8 release is aware for the problem and want handle this better, by the way i'm sick of it to handle microsoft code issues....)