PDA

View Full Version : The Wondrous World Wherein Shapes Change Shapes



jlingle
02-22-2012, 03:43 AM
In PP2010 I have been working on an App that updates "Template Slides" from an Excel spreadsheet. A "control slide" at the beginning of a deck of template slides figures out what slides are in the deck and then works through and updates them one-by-one. Everything was working fine with each of the single template slides, but when I put several templates together one of my chart slides bombs. After a lot of investigating I discover my chart shape on the template has changed from a msoPlaceholder (#14) to a msoEmbeddedOLEObject (#7). Even more interesting, I discover that if I paste into the deck a new copy of the template slide it holds onto its msoPlacehoder shape. However, if I delete the slide above it (the slide with the chart that has somehow transmuted to a msoEmbeddedOLEObject) as the new template moves up into the position held by the deleted slide, its chart shape changes to an msoEmbeddedOLEObject.

Can anyone help me understand why these shapes are transmuting as I insert/paste slides into the deck and how to keep it from happening? :roll:

John Wilson
02-22-2012, 07:04 AM
You would need to give a lot more info. But some general things:

If you are deleting slides in a loop ALWAYS work backwards:

eg

For i = ActivePresentation.Slides.Count To 1 Step -1
' If whatever then ActivePresentation.Slides(i).Delete
Next

NOT

For i = 1 To ActivePresentation.Slides.Count
' If whatever then ActivePresentation.Slides(i).Delete
Next

You will get a different result for a type 7 shape if it is IN a placeholder.

Try a Check for .PlaceHolderFormat.ContainedType

If oshp.Type = msoPlaceholder Then _
MsgBox oshp.PlaceholderFormat.ContainedType

jlingle
02-22-2012, 07:10 AM
o.k., all useful. I will experiment a bit more to try and identify the exact circumstances under which the shape changes. I got tired after my long afternoon of figuring out what was happening. The most interesting thing to me was that the placeholder shape on the slide seemed to change to a OLE shape without running any VBA code. I was simply "cut-and-pasting" slides, watching the shape change shape, not running code. Not sure I made that clear in my initial post.