首页 文章

使用ID / Title / Whatever在PowerPoint VSTO API中标识幻灯片上的形状

提问于
浏览
1

我正在写一个PowerPoint 2010 AddIn . 简而言之,这就是我所做的:

  • 使用大量已定义的布局幻灯片创建PowerPoint模板(* .potx)

  • Write插件可自动完成演示完成后的一些常见任务 . 其中之一是插入Agenda Slide(在SlideMaster中定义为Layout)作为每个部分的第一张幻灯片 .

  • 插入议程幻灯片后(这很简单: newAgendaSlide.MoveToSectionStart(sectionNumber) )我必须设置两个Shape对象的文本(一个位于幻灯片顶部,第二个位于底部/右角 - 让我们调用Header&页脚)到当前PowerPoint部分的名称,在当前部分的每张幻灯片上 .

现在,我知道如何获得部分 Headers :

Presentation.SectionProperties.Name(sectionNumber)

我知道如何遍历 Slide 对象上的 Shape 对象 . 但我不知道如何访问正确的Shape . 我可以'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'的形状,然后完全确定相同的属性在幻灯片上具有相同的值?

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

1 回答

  • 3

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

    我会使用标签来识别您添加的形状 . 当它有时间操纵其中一个时,看看幻灯片上是否有一个(测试你添加的标签),如果找不到,请添加自己的 . AirVBA示例:

    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
    

相关问题