Accessing PowerPointApp.ActiveWindow during a slide show causes an exception (PowerPoint 2016)

Add-in Express™ Support Service
That's what is more important than anything else

Accessing PowerPointApp.ActiveWindow during a slide show causes an exception (PowerPoint 2016)
 
momsoft




Posts: 76
Joined: 2004-06-16
I use PowerPointApp.ActiveWindow.ViewType very often to detect the state of PowerPoint. But I have just seen that accessing PowerPointApp.ActiveWindow generates the following exception if there is a SlideShow running:

Exception EOleException in module PowerTOC.dll at 00543EA4. Application (unknown member) : Invalid request. There is no currently active document window.

I am catching the exception, so it is not apparent while PowerPoint is running, but I would prefer to not provoke it in the first place.

So, my question is what is the best way to determine the View used by PowerPoint.

Thank you very much
Posted 06 Jul, 2017 07:59:14 Top
Andrei Smolin


Add-in Express team


Posts: 14140
Joined: 2006-05-11
Hello Manuel,

There are several ways. You can handle the Application.SlideShowBegin and Application.SlideShowEnd events to find out if a slide show is in progress. You can call Application.SlideShowWindow; it produces an exception if there's no slide show window. You can loop through the DocumentWindows collection checking the DocumentWindow.Active property. You can handle Application.WindowActivate and Application.WindowDeactivate events to trace the DocumentWindow currently active.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 06 Jul, 2017 08:54:01 Top
momsoft




Posts: 76
Joined: 2004-06-16
Andrei,

Thank you very much.

From what you say, I think that the best procedure could be to have a global boolean variable which is set to true on Application.SlideShowBegin and to false on Application.SlideShowEnd and check its value before trying to access the PowerPointApp.ActiveWindow object.

I will check it.

Regards,

Manuel
Posted 06 Jul, 2017 11:01:42 Top