Powerpoint 2010 Multiple Instances
I have seen numerous posts on this subject here, but none seem to answer this issue directly. I want to control two instances of Powerpoint running on a second monitor.
The ideal solution looks like this:
PowerPoint.Application PPTViewer1 = new PowerPoint.Application(); PowerPoint.Application PPTViewer2 = new PowerPoint.Application();
I can do this manually, simply by starting two instances of PowerPoint, loading the presentation, and starting the slide show from each instance. I can toggle back and forth between the two slide shows manually, with each being brought to the front as expected.
So... how do I do this programatically using VSTO and C#?? Like others before me, I see that the Interop.PowerPoint interface will create only the single instance. If that were not the case, then I could achieve the results I am looking for easily enough.
Additionally, I am not looking for a third party component for this task.
Any help is appreciated.
Thanks in advance.
It may appear that you're running multiple instances of Powerpoint, but you're not. It only allows one instance of itself. If you see two instances of Powerpnt.exe in the task list, as sometimes happens, it means that something's gone wrong and left a zombie in memory.
May not be totally ideal but here is a reference that suggested to start an instance as a different user (Note that this site is for PowerPoint 2007).
runas /user:username "C:\Program Files\Microsoft Office\Office12\POWER PNT.EXE"
Each instance of the Powerpoint COM object shares the same fullscreen display window. I know of no method to switch which presentation has that window
The solution is to host the Powerpoint display in your own window
This therefore allows you to scale the window and show multiple presentations on one monitor, or move it from one monitor to another?
var display1 = new FullScreenDisplay(); // A form with BorderStyle = None display1.Show(); application1 = new PowerPoint.Application(); presentation1 = application1.Presentations.Open2007(....); var slideShowSettings1 = presentation1.SlideShowSettings; slideShowSettings1.ShowType = PowerPoint.PpSlideShowType.ppShowTypeSpeaker; var slideShowWindow1 = slideShowSettings1.Run(); IntPtr hwnd1 = (IntPtr)slideShowWindow1.HWND; SetParent(hwnd1, display1.Handle); var display2 = new FullScreenDisplay(); display2.Show(); application2 = new PowerPoint.Application(); presentation2 = application2.Presentations.Open2007(....); var slideShowSettings2 = presentation2.SlideShowSettings; slideShowSettings2.ShowType = PowerPoint.PpSlideShowType.ppShowTypeSpeaker; var slideShowWindow2 = slideShowSettings2.Run(); IntPtr hwnd2 = (IntPtr)slideShowWindow2.HWND; SetParent(hwnd2, display2.Handle); display1.BringToFront(); // to show slideshow 1 // or display2.BringToFront(); // to show slideshow 2 // To advance a slide presentation1.SlideShowWindow.View.Next(); // or presentation2.SlideShowWindow.View.Next(); // To exit, note order! presentation2.SlideShowWindow.View.Exit(); presentation1.SlideShowWindow.View.Exit(); Application.Exit();
This is a hack, and may not work in future versions of Powerpoint?
You also need this import
[DllImport("user32.dll", SetLastError = true)] static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);