none
Identify Shape on the slide in PowerPoint VSTO API using ID/Title/Whatever RRS feed

  • Question

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

    Thanks,Paweł

    Tuesday, January 24, 2012 8:35 PM

Answers

  • When you create the shape give it a name.  The command is: Slide(x).Shapes(y).Name = "Your Name"
    Kind Regards, Rich ... http://greatcirclelearning.com
    Wednesday, January 25, 2012 1:05 AM

All replies

  • When you create the shape give it a name.  The command is: Slide(x).Shapes(y).Name = "Your Name"
    Kind Regards, Rich ... http://greatcirclelearning.com
    Wednesday, January 25, 2012 1:05 AM
  • 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.

    Wednesday, January 25, 2012 9:56 AM
  • Hi Pawel,

     

    Thanks for posting in the MSDN Forum.

     

    Did you solve your issue? It’s based on my experience that Rich’s solution can work. If you have better solution would you please here it here? It’s very beneficial for all community members who have similar problem to see how you solved it.

     

    Have a good day,

     

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Friday, January 27, 2012 6:18 AM
    Moderator
  • Hi Rich,

           We are finding a performance issue in VSTO compared to VBA.

    Little Description on what we are doing (VSTO Approach):

    1. We are having a power point with 250 slides.

    2. We need to get a particular slide (say 200) using place holder in some of the slides. Each slides can have 'n' number of place holders in it.

    3. We are looping through all the slides and verify if the place holder text matches user input text, then we are getting the slide number and breaking the loop.

    Note: Windows application with PIA's are used to verify the total time lapsed to fetch 200th slide from the power point.

    Issue:

    1. VSTO is taking around 8-10 sec to get 200th slide

    2. VBA is taking 2-3 sec to get 200th slide.

    Request you to provide any update why VSTO is slower than VBA or is there any better approach than above mentioned one.

    Let me know if you require any further details.

    Thanks in Advance 

    Sricharan Vasista


    MSDN

    Monday, June 3, 2019 12:56 PM
  • Hi Sricharan,

    My experience has been that a VSTO solution always runs a bit slower than a VBA based solution. I don't know why exactly that is, but I suspect it's the overhead of the VSTO methods.

    You should check if there are ways that you can eliminate the checking every slide's placeholders. For example, can you eliminate Title slides? Can you eliminate a slide because it doesn't have the particular layout that would contain the text you are searching to find? Instead of performing the search as you are, can you programmatically invoke the built-in Find function and let PowerPoint's native code locate the text strings you want to find?

    Hope this helps


    Kind Regards, Rich ... http://greatcirclelearning.com

    Monday, June 3, 2019 3:46 PM
  • Hello Sricharan,

    I would consider managing placeholder texts and storing them someplace. In this case, you would find the slide and placeholder in a couple of moments.


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    Please mark answers and useful posts to help other developers use the forums efficiently.

    Tuesday, June 4, 2019 7:15 AM
  • thanks for your suggestion.  Let me check on it and update you.

    MSDN

    Wednesday, June 5, 2019 12:55 PM