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?
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.
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.
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?
Based on your comment to Mikael, there is another solution. This is VBA, but easily portable to C#. Just open the presentation (hidden) and export each slide as a PNG. Then you can have those PNGs display in your column.
Dim ap As Presentation
Set ap = Presentations.Open(FileName:="yourppt.pptx", WithWindow:=msoFalse)
Dim s As Slide
For Each s In ap.Slides
s.Export s.Name, "PNG"
Next
Then, when someone clicks something, the first one can close and your new PPT can show.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With