Identify active slide in C#

泄露秘密 提交于 2021-02-08 07:48:23

问题


I would like to know which is the current slide viewed by the user in PowerPoint (in edition not presentation). I used an SlideChange event with var new Index = Application.ActiveWindow.View.Slide.SlideIndex.

The problem is when the cursor on the thumbnail panel on the left is not on a slide but between two. In that case, I have an error View (unknown member) : Invalid request. No slide is currently in view. which is normal because there is no view pointed. Unfortunately SlideChange event is also raised in that case.

I would like to ignore cases when there is no slide pointed. But I can't find any property that indicates it, so I could do something like if(Application.ActiveWindow..... != ... ){doThis}.

The only (bad) way I have found is to make a try/catch (but it slows the application, it is raised at each new slide with an exception). Do you have any idea to solve my problem ?


回答1:


You can use the following code to get the active slide object:

var slide = Application.ActiveWindow.View.Slide



回答2:


the below code is able to find which slide is currently viewed

SlideShowWindows(1).View.Slide.SlideIndex

but this will work for slideshow only

OR

use below code..i am not sure but it may help

if (Globals.ThisAddIn.Application.Active == MsoTriState.msoTrue &&
            Globals.ThisAddIn.Application.ActiveWindow.Panes[2].Active == MsoTriState.msoTrue)
        {
           bla bla
        }


来源:https://stackoverflow.com/questions/50816648/identify-active-slide-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!