使用 ID/Title/Whatever 在 PowerPoint VSTO API 中识别幻灯片上的形状 [英] Identify Shape on the slide in PowerPoint VSTO API using ID/Title/Whatever

查看:47
本文介绍了使用 ID/Title/Whatever 在 PowerPoint VSTO API 中识别幻灯片上的形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写 PowerPoint 2010 插件.简而言之,这就是我所做的:

I'm writing a PowerPoint 2010 AddIn. In a nutshell this is what I do:

  1. 使用大量定义的布局幻灯片创建 PowerPoint 模板 (*.potx)
  2. 编写插件,自动执行演示完成后的一些常见任务.其中之一是插入议程幻灯片(在 SlideMaster 中定义为布局)作为每个部分的第一张幻灯片.
  3. 插入议程幻灯片后(这很容易:newAgendaSlide.MoveToSectionStart(sectionNumber))我必须设置两个 Shape 对象的文本(一个在幻灯片顶部,第二个一个位于下/右角 - 让我们在当前部分的每张幻灯片上将页眉和页脚)称为当前 PowerPoint 部分的名称.
  1. Create PowerPoint Template (*.potx) with a great deal of defined Layout slides
  2. Write plugin that automates some common tasks that are made after presentation is done. One of them is to insert Agenda Slide (defined as Layout in SlideMaster) as the first slide in every section.
  3. After the Agenda Slide is inserted (that was pretty easy with: newAgendaSlide.MoveToSectionStart(sectionNumber)) I must set the text of two Shape objects (one on the top of the slide, and second one is located in bottom/right corner - let's call the Header & Footer) to the name of current PowerPoint section, on every slide in current section.

现在,我知道如何获取部分标题了:

And now, I know how to get section's title:

Presentation.SectionProperties.Name(sectionNumber)

而且我知道如何遍历 Slide 对象上的 Shape 对象.但我不知道如何访问正确的Shape.例如,我不能确定我的页眉/页脚形状是否将 Id 设置为特定值?有没有办法在Layout的Shape上设置某种属性,然后完全确定相同的属性在Slide上会有相同的值?

and I know how to iterate through Shape objects that are on the Slide object. But I don't know how to access right Shape. I can't be sure that, for instance, that my Header/Footer shape will have Id set to particular value? Is there any way to set some kind of property on Layout's Shape, and then be completely sure that the same property will have the same value on the Slide?

总而言之(并希望说清楚):我想创建一个具有 x 个形状的布局幻灯片(在 SlideMaster 中),并且能够访问真实演示幻灯片上的特定幻灯片.

To sum up (and hopefully make it clear): I would like to create a Layout slide (in SlideMaster) with x number of shapes, and be able to access particular slide on real presentation slide.

推荐答案

我可能会自己插入页眉/页脚形状,而不是使用 PPT 的(严重损坏的)页脚.

I would probably insert the Header/Footer shapes myself rather than using PPT's (badly broken) footers.

我会使用标签来标识您添加的形状.当需要操作其中一个时,查看幻灯片上是否已经有一个(测试您添加的标签),如果没有找到,请添加您自己的.AirVBA 示例:

I'd use tags to identify the shapes you've added. When its' time to manipulate one of them, look to see if there's one on the slide already (testing for tags you've added) and if it's not found, add your own. AirVBA example:

For each oSh in oSlide.Shapes
  If Len(oSh.Tags "MyShape") > 0 Then ' its' your footer
    Set oFooter = oSh
  End If

  If oFooter is Nothing then  ' not there, add one:
    Set oFooter = ... add the shape here
    ' add the tags
    oFooter.Tags.Add "MyShape", "Footer"
    With oFooter
      ' format it, add text, whatever
    End with
  End if
Next

这篇关于使用 ID/Title/Whatever 在 PowerPoint VSTO API 中识别幻灯片上的形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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