0
votes

I am using the Powerpoint Interop to develop a Powerpoint 2010/2013 Add-In. As part of this, I need a reliable way to map picture shapes to filenames.

My original plan was to simply look them up based on order of appearance in the slides, keeping a counter of images found. I would then use this to look into the .pptx archive and figure out what images were on what slides (e.g. first picture found -> Picture 1.jpg, etc).

However, this does not seem to work in cases where a single image appears on more than one slide. Shape.Id does not seem to be consistent per shape across slides, and Shape.Name is stated to only be per slide in the MSDN documentation.

Is there a reliable way to compare picture shapes across slides, or will I have to resort to comparing width/height to try and find matches?

1

1 Answers

1
votes

It's not clear whether you're working with the unzipped contents of the PPTX file or not, but that's probably what you'll need to do.

Unzip the PPTX file and you'll find within the zip:

\ppt\slides_rels

Within the _rels folder, you'll find, eg. slide1.xml.rels

This is the file that points you to the other resources used by the slide.

<Relationship Target="../media/image2.jpeg" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Id="rId3"/>

../media/image2.jpg for example, refers you to the /media folder in the root of the archive; it'll contain image2.jpg

The slidex.xml.rels files for other slides that include copies of this image will point to the same image in the /media folder.

Of course, if you're just looking to do something with the images in the presentation, look in the /media folder and Bob's avuncular.