• Programmatically identify slide number “field”

    Home » Forums » AskWoody support » Productivity software by function » MS PowerPoint and presentation apps » Programmatically identify slide number “field”

    Author
    Topic
    #475864

    Hi guys,

    I’ve written an application that parses all TextRanges in Master, CustomLayouts and Slides using automation.

    This works great, but I’ve noticed that I get the text “” where the current slide number is supposed to be displayed (as it shows when you switch to Master View).

    My question is: do I have a way to programmatically identify the “field” used to display the slide number, so that I can process it and replace it with the correct value? Or can I retrieve the “computed” value directly from a slide?

    I first thought of identifying the “field” by looking for “” in the TextRange, but this isn’t a reliable method as this “field” reads as “” in French and “” in German for instance. I can see that in PowerPoint the field isn’t plain text and is highlighted when you select it. So what kind of “object” is this exactly? How does PowerPoint identifies it as a “field”/”tag”/”whatever”?

    Viewing 4 reply threads
    Author
    Replies
    • #1274805

      You might try something like this

      Code:
      For Each oPlaceHolder In ActivePresentation.SlideMaster.Shapes.Placeholders
           ' Look for the slide number placeholder.
           If oPlaceHolder.PlaceholderFormat.Type = ppPlaceholderSlideNumber Then
               'do something
           End If
      Next
      • #1274835

        Hi Andrew,

        Thanks for your reply. Unfortunately, the slide number tag I’ve been fighting with hasn’t been placed in a placeholder but in a simple Textbox, so the solution you suggested won’t work in this case 🙁

        I was thinking: maybe I could programmatically insert a dummy TextBox somewhere in the Presentation I’m processing, then get its TextRange, call the API InsertSlideNumber and check what localized text PowerPoint produces ( or or etc.). This done, the dummy TextBox would be deleted, and I could process myself all the occurence of , , I find with the current slide number.

        This technique however is not perfect, as any typed as plain text in the Presentation would be processed as a SlideNumber tag…

        Any other suggestions? Any thoughts?

    • #1274866

      I think you are out of luck trying to reference the slide number as a field in PPT. (Please prove me wrong, I’d be delighted to hear it).
      Are you trying to find the slide number value or set it? and if so, why in the master?

      Perhaps a different approach is in order.

    • #1274951

      Hi WebGenii,

      To summarise the situation: I have written a program that takes in input any PowerPoint presentation and generates in output a converted presentation (in an internal format, this is not important here).

      So wherever I see a proper SlideNumber (1, 2, 3, etc.) in the input Presentation, I can see in a ugly in my output document.

      My problem is: where PowerPoint’s APIs gives me a text in input such as “text text text text text text”, I shall be able to identity that “” isn’t actually simple plain text, but a “marker” that is aimed to be replaced with an actual slide number.

      As explained in the previous posts, I do not currently have a 100% reliable method to identify this as a “marker” (or “tag”, or “field”, or whatever you would like to call this) for a slide number.

    • #1277969

      Nobody knows anything about the specifities of PowerPoint’s slide number? 🙁

    • #1278039

      PPT’s object model is plain ugly – a sentiment I’m sure you’ve heard before. I did do a little research, but was not able to get any further than you’ve got yourself.

    Viewing 4 reply threads
    Reply To: Programmatically identify slide number “field”

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: