I am writing a simple module that uses Microsoft.Office.Interop.PowerPoint to determine if a PowerPoint slideshow is active and if so which slide is currently being presented. This works great when I use Microsoft.Office.Interop.PowerPoint.Presentation to open t开发者_开发知识库he presentation in my code. If possible, I want to check to see if an instance of Power Point is already open and if so attach to it instead of opening a new instance.
TIA
Create a new Interop.PowerPoint.Application
and check whether your file is in the Presentations
collection.
Unlike Word or Excel, PowerPoint is a single-instance application; your new Application
instance will automatically connect to any open copy of PowerPoint.
you can check by calling Marshal.GetActiveObject ("Powerpoint.Application")
- it gives an exception if powerpoint is not running... see http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.getactiveobject.aspx
If it is running this gives you an object...
精彩评论