PDA

View Full Version : Creating ShapeRange to align shapes using object array



tbaker818
08-24-2015, 03:03 PM
I've seen examples like
Set shShapeRange = myDocument.Shapes.Range(Array(1, 3)) or
Set shShapeRange = myDocument.Shapes.Range(Array("Oval 4", "Rectangle 5")) to refer to multiple shapes. In my case, rather than referring to the shapes using index numbers or names, I'd like to use objects. Theoretically, I haven't been able to find anything wrong with this, but it just isn't working.

If I take an array of names that was working for me and replace those string names with the names of objects, something like
Array(shCurrentShape, shScaleBreak) which refers to the same shapes, I get the error "Shapes(unknown member): Failed"

Has anyone tried this? Is this a limitation of PowerPoint?

John Wilson
08-26-2015, 03:43 AM
The array needs to be names or index so you would have to say

Array(shCurrentShape.Name, shScaleBreak.Name)
or
Array(shCurrentShape.ZOrderPosition, shScaleBreak.ZOrderPosition)

tbaker818
08-28-2015, 02:53 PM
In the case of the ZOderPosition, would the shapes already have to be overlapping?

John Wilson
08-29-2015, 11:43 AM
No, but it can be a little buggy if there are already groups on the slide. Worth trying though. The names can also fail because fairly stupidly MSFT allows duplicate names which will cause problems.