如何使用Office主互操作程序集在c#中通过其Id / Name获取Shape对象(Powerpoint) [英] How to Get Shape object(Powerpoint) by its Id/Name in c# using Office Primary Interop Assemblies

查看:179
本文介绍了如何使用Office主互操作程序集在c#中通过其Id / Name获取Shape对象(Powerpoint)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Open XML从功率点演示中提取了Shape Ids,我想获得COM对象 使用主互操作程序集对那些id。可以帮助吗?

I have extracted Shape Ids from power point presentation using Open XML, I want to get COM object  against those ids using primary interop assemblies. can any one help?

最终目标是使用Shape.ActionSetting触发Action。

Eventual goal will be triggering Action using Shape.ActionSetting .

谢谢

推荐答案

嗨kkhanzada,

Hi kkhanzada,

您可以遍历形状并比较它们的
Shape.ID
,带有您的ID。

You could iterate through shapes and compare their Shape.ID with the id you got.

但请注意,不同幻灯片中的形状可以具有相同的形状ID。

However, please note that, shapes in different slide could have the same shape id.

以下是迭代完所有幻灯片的示例,并在找到符合id的第一个形状后返回。

Here is the example to iterate through all the slides and return after finding first shape which meets the id.

            long id = 5;

            foreach (PPT.Slide slide in activePresentation.Slides) {

                foreach(PPT.Shape shape in slide.Shapes)

                {

                    if (shape.Id == id) {

                        //set ActionSetting for your need

                        //here is the example to  reutrn to first slide when the mouse is over the shape

                        shape.ActionSettings[PPT.PpMouseActivation.ppMouseOver].Action = PPT.PpActionType.ppActionFirstSlide;

                        return;

                    }

                }

            }

最好的问候,

Terry


这篇关于如何使用Office主互操作程序集在c#中通过其Id / Name获取Shape对象(Powerpoint)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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