识别C#中的活动幻灯片 [英] Identify active slide in C#

查看:69
本文介绍了识别C#中的活动幻灯片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道哪个是用户在PowerPoint中查看的当前幻灯片(在版本中不是演示文稿).我将 SlideChange事件 var new Index = Application.ActiveWindow.View.Slide.SlideIndex 一起使用.

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.

问题是,左侧缩略图面板上的光标不在幻灯片上,而是在两个之间.在这种情况下,我有一个错误视图(未知成员):无效的请求.当前没有幻灯片.这是正常的,因为没有指向任何视图.不幸的是,在这种情况下也会引发SlideChange事件.

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.

我想忽略没有幻灯片指向的情况.但是我找不到任何指示它的属性,因此可以执行 if(Application.ActiveWindow .....!= ...){doThis} 之类的操作.

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}.

我发现的唯一(坏)方法是进行 try/catch (但会减慢应用程序的速度,在每张新幻灯片上都会出现此异常).你有解决我问题的主意吗?

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 ?

推荐答案

您可以使用以下代码获取活动幻灯片对象:

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

var slide = Application.ActiveWindow.View.Slide

这篇关于识别C#中的活动幻灯片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆