none
OpenXML Presentation - Identifying paragraphs... RRS feed

  • Question

  • I have an interesting problem that I would like to throw out to you all - see if anyone can think of anything I haven't.

    What I need to be able to do here is to somehow assign / determine identifers for all the paragraphs in a Presentation. I then need to be able, at some point in the future, to open / manipulate that presentation using OpenXML, and the identifiers have to be available for use at this point.

    In short then, I need some form of persistent identifier.

    I've tried looking at the OpenXMLFormat itself, and cannot see anything there that I can use that's already built in. If anyone knows of anything, any element that's already in the schema I might use, any attribute etc, then please shout up...

    Trying to solve this problem myself, I have written code using XLinq and SharpZipLib to open up the various xml files and add a custom attribute to every element - the attribute basically containing a Guid. The code does what it is supposed to - but both Powerpoint and OpenXML 2.5 will then no longer talk to the file - presumably because I have introduced attributes that are not in the schema... I could live without Powerpoint being able to access the file at this point, but OpenXML is a bit of a blocker because the file will be undergoing some processing later on that has a definite dependency on the OpenXml library.

    Anyone got any ideas?

    Friday, May 30, 2014 1:34 PM

Answers

  • Hi Martin

    Mmm, only a round-about possibility occurs to me, but without knowing more about how the presentation will be used (edited) I'm not sure it's feasible.

    Presumably, the code that creates the "identifiers" needs to run when the presentation is being saved, or after it's been saved? Otherwise, further editing could add additional paragraphs or delete existing ones?

    So what occurs to me is that you can TAG the Shapes (with a GUID) on the presentation that contain the text (paragraphs). You can then scan the Shape to count the number of paragraphs it contains and create a combination Tag + paragraph counter ID (for example).

    Create a Custom XML Part in the presentation to store this information. You can then "look up" where to find a specific identifier in the presentation, i.e. locate the Shape with the TAG then get the paragraph at location n.


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, May 30, 2014 7:05 PM
    Moderator