Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Aug 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Programmatically identify slide number "field"

    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 "<N>" in French and "<Nr.>" 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"?

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    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
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    New Lounger
    Join Date
    Aug 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 <N> or <Nr.> etc.). This done, the dummy TextBox would be deleted, and I could process myself all the occurence of <#>, <N>, <Nr.> 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?

  4. #4
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts
    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.
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

  5. #5
    New Lounger
    Join Date
    Aug 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  6. #6
    New Lounger
    Join Date
    Aug 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nobody knows anything about the specifities of PowerPoint's slide number?

  7. #7
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts
    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.
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •