2

I'm currently writing a process that generates Powerpoint reports programmatically from a given template using the MSXML library via VBScript. The only manipulation of the XML I'm doing is to duplicate slides, insert data into the Excel datatables for charts and a couple of title-text text replacements. I'm testing on 2 templates which are identical in terms of the charts but differ on the styles and layouts. One of the templates gives me a working output pptx file whereas the other shows this error when opened:

Powerpoint error

Now what I want to know is what's the best/easiest way of finding the cause of this error? I've tried diffing the XML between the template, output and Powerpoint's corrected output but differences appear in so many different places in so many different files that it's a very lengthy process. Are there any checking/validation tools that could help me here? I've checked the XML against the schemas but the XML seems to be valid.

I can't upgrade to tools such as Microsoft's OpenXML SDK for .NET and the process must be implemented in the VBScript/MSXML process I'm currently using.

  • 1
    This error is purely related to invalid XML. If you edit your response to show the output in the areas that you appended in both the one that works and the one that doesn't, it should be fairly easy to tell where the issue is. However, it sounds like you're doing a number of changes (Excel, duplicating slides and updating text). I'd recommend doing one at a time to test which update is causing the issue and then post that code/XML. – Todd Main Aug 19 '10 at 15:40
  • not quite: I'm making *exactly* the same changes to both input presentations, so showing just the areas that i've changed won't help me –  Aug 20 '10 at 07:43
  • Well, if you confirm that they are *exactly the same* then the only possible answer is that you are manually corrupting the file after your code is written, for example you open the saved .pptx as a .zip and add/edit/delete something manually. That is the *only* way it would be corrupted if your code is not doing it and you're saying that your code is not doing it. If you're willing to troubleshoot this on the premise that your assumption may be wrong, I'd be happy to help - I'm very, very well versed in PresentationML and DrawingML. – Todd Main Aug 21 '10 at 07:29
  • no, what I'm saying is the changes I'm making to both files are exactly the same (ie the input data is the same and the changes to the datatables are exactly the same). The differences are in the original files which seems to mean that something in one file is incompatible with the changes I'm making, despite it working on many previous examples I've tried. –  Aug 23 '10 at 11:19
  • @thegravytalker: Right, that's what I'm saying too, but I guess I didn't say it well. If you're writing the exact same thing, but to a different template, then the template that fails is failing because your XML is invalid for what it expects. This can happen - maybe you're writing to a `title` where the template expects you to write to a `ctrTitle`. The recommendation is to do your steps one by one, figure out which one is causing the invalid XML and post the that XML plus the valid equivalant. Then we'll know what is causing the error. – Todd Main Aug 24 '10 at 00:53
  • yeah, but I was kind of hoping there was a better way, such as a tool that checks the XML and tells you what and where the problem is. –  Aug 24 '10 at 07:46
  • @thegravytalker: Just wanted to follow up to see if the below is getting you any closer to what you need. – Todd Main Sep 10 '10 at 17:19

1 Answers1

2

For basic validation of Open XML documents, you can use the Open XML SDK. See these two links as a start:

For non-SDK validation, it is done mostly by hand. Most errors in PowerPoint relate to:

  1. Mismatch between slide layout and master slide layout. <- this one is more common when writing to different templates.
  2. Relationship Ids (rId) don't match.
  3. Incorrect entries in [Content_Types].xml.

One technique is to choose "Repair" on the invalid slide deck and then save the repaired deck with a different name. You can then use the DiffOPC tool to run against the repaired one and the one with errors to try to determine what was repaired - that will usually be a great indication of what was incorrect in the first place.

Todd Main
  • 28,951
  • 11
  • 82
  • 146
  • thanks for your input, but I can't really mark this as the answer because my original question states that I can't use the SDK. This is because I don't have access to a recent enough .NET compiler. I quick glance at your first link looks like achieving the same result as simply validating the XML against the schemas that I'm already doing using the MSXML COM library. –  Aug 25 '10 at 12:07
  • There are no automated validation tools, that I know of, outside of the SDK. For any validation not using the SDK, it will have to be done manually, as mentioned in the comments. That will require stepping through the code that is produced to ensure it is valid XML in the context of where it is inserted/deleted/edited. – Todd Main Aug 26 '10 at 05:02
  • yes, I agree with you on this. Stepping through each change I'm making is probably the only option but that's also a general programming solution. I was hoping for a specific Office XML tool for PowerPoint that would actually point me in the direction of the error instead of PowerPoint just saying "there's an error" when it loads the presentation. It's odd that Word 2007 goes a bit further to report what's wrong and PowerPoint doesn't. –  Aug 26 '10 at 07:58
  • None exist, as far as I know, outside of the SDK. But there are some techniques. I've listed above. – Todd Main Aug 26 '10 at 18:04