1
votes

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

  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)

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?

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.

1

1 Answers

3
votes

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

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