tags:

views:

301

answers:

3

I'm working on a project where I need to use PowerPoint from C#.net. Initially, I always created one single instance. As of today, I would like to have multiple instance running. I do that like so:

Type powerpointType = Type.GetTypeFromProgID("PowerPoint.Application");

object instance1 = Activator.CreateInstance(powerpointType);
object instance2 = Activator.CreateInstance(powerpointType);

but when I ask for the handle of both instances, by calling

hwnd = (int)powerpointType.GetProperty("HWND").GetValue(instance1, null);

then I get the same handle twice. My conclusion is that the application is started just once, and the TaskManager comfirms that: Only one process.

How come there is only one instance of PowerPoint running, and how can I make it work?

+3  A: 

PowerPoint as well as Word shares the same instance. Excel on the other hand lets you have multiple instances. In order to have two instances running you need to start up the other instance as a different user.

Why do you need multiple instances? In order to show two presentations on two monitors?

Mikael Svenson
The app I'm writing is (among a lot of other things) for presenting PowerPoint Presentations. If you add a presentation to a column (kind of working area), that column should be filled with thumbnails of the slide of the ppt. There for I need PowerPoint. After that, one can present the ppt. That also launches PowerPoint. These things should be able to happen at the same time, and you should be able to open a ppt while also quitting another column with a ppt.
Excel20
I think you then need to run two instances under different users, or use PowerPoint from Office 2010 (beta) which is supposed to work with multiple windows.
Mikael Svenson
+3  A: 

Instead of multiple instances, why not reference the multiple open presentations in the single instance?

When a user "Quits a column," you can just close that one presentation, but leave PPT open, unless it is the last open presentation.

Jay
+2  A: 

This link discusses how to use a new user account to create multiple instances of PowerPoint. It works fine if you're always running it off the same computer, but isn't particularly easy to distribute.

Nick
This wouldn't be preferable, since the app is going to be distributed amongst hundreds of users, possibly with low to no computer skills.
Excel20