none
creating PPTX by code alsways ends in invalid content RRS feed

  • Question

  • Hello folks,
    I am currently playing around with the creation of PowerPoint 2007 documents with Office Open Xml.
    For thing that I wanted to achieve is: adding a single slide into an empty presentation (only 1 slidemaster with only one slide layout). The empty PPTX I have created with PP 2007 myself. 

    Attempt 1:
    - use the empty PPTX
    - open the package with Office OpenXml SDK 2.0 (PresentationDocument)
    - add a new SlidePart to the Presentation
    - generate the slide content and save it to the slide content
    - link the SlidePart to the first SlideLayout of the first SlideMaster
    - save and close the package
    - try to open in PP 2007

    = error message that there is unreadable content, I may want to recover the document ..
    = if I try to recover it shows the slide with the content
    = it won't open at all in PP 2003 (compatibility pack installed)


    Attempt 2:
    - use the empty PPTX
    - open it in PP 2007 and add a new slide with some content by hand
    - open the package with Office OpenXml SDK 2.0 (PresentationDocument)
    - add a new SlidePart to the Presentation
    - generate the slide content and save it to the slide content
    - link the SlidePart to the first SlideLayout of the first SlideMaster
    - save and close the package
    - try to open in PP 2007

    = works like a charm, no problems at all, not even under PP 2003

    .. so obviously the slide itself is okay but there seems to be problem with the linking to SlideMaster and SlideLayout

    What am I missing? Does anyone have an idea where the problem could lie?

    Thx in advance, Frank

    P.S. I could provide all the code and pptx's if needed for analysis
    Thursday, August 27, 2009 10:25 AM

Answers

  • Well ... the answer is pretty simple ... thanks to the OOXMLValidator from Codeplex I could find out that the MINIMUM value for the id of the SlideId objects (used in the presentations SlideIdList) has to be 256. When starting with an empty slide this one has already the 256. So all new slides will receive higher numbers which makes it work.

    HTH anyone else as well.
    Frank
    • Marked as answer by Frank Förster Thursday, August 27, 2009 2:57 PM
    Thursday, August 27, 2009 2:57 PM

All replies

  • Well ... the answer is pretty simple ... thanks to the OOXMLValidator from Codeplex I could find out that the MINIMUM value for the id of the SlideId objects (used in the presentations SlideIdList) has to be 256. When starting with an empty slide this one has already the 256. So all new slides will receive higher numbers which makes it work.

    HTH anyone else as well.
    Frank
    • Marked as answer by Frank Förster Thursday, August 27, 2009 2:57 PM
    Thursday, August 27, 2009 2:57 PM
  • At your service! ;)
    Tuesday, September 1, 2009 6:41 AM