Link to home
Start Free TrialLog in
Avatar of WeThotUWasAToad
WeThotUWasAToad

asked on

Align > Distribute multiple objects in PowerPoint by the order inserted (back to front)

Hello,

In MS PowerPoint, is there a way to Distribute multiple objects by the order they were inserted (ie back to front), rather than by their pre-Distribute position?

The Distribute controls in PowerPoint, ie:

        Home > Arrange > Align > Distribute Horizontally/Vertically

are extremely handy for distributing and evenly spacing objects horizontally and/or vertically. When this occurs, the most extreme objects and locations  (furthest up/down/left/right) of the final distribution are determined, as far as I can tell, by the most extreme side-of-an-object position before the distribution.

For example, suppose you paste a dozen images (of varying sizes) into a single slide in PowerPoint. By doing so, all of the images (objects now) position themselves in the center of the slide.* As a result, the only completely-visible image is the one that was pasted last.

Also, for the purposes of the Back/Front controls (ie Send Backward, Bring Forward, etc) the objects are "layered" in the order they were pasted. In other words, the furthest back object  can be numbered #1, the next furthest back #2, and so on up to the front object #12.

Now suppose you drag object #12 far below and to the right of all other objects and drag object #11 far above and to the left of all other objects.  If you then Select All and click one of the Distribute buttons, all of the objects will be distributed between the extremes, #11 & #12, with the 10 other objects taking a position based on their relative size (original location of their sides).  In other words, it is impossible in this scenario for object #1 to be distributed to the upper/left extreme.

I'm wondering if there is a way to distribute objects according to their respective Back/Front order rather than according to their size or where they reside prior to distribution.  

I don't see any menu options or shortcuts in PowerPoint Options > Quick Access Toolbar > All Commands but I'm wondering if it can be accomplished with VBA code.

Thanks

*Unlike images, inserted shapes, etc., appear at the location of the mouse cursor so for simplicity, only images are considered in the example.  However, the main point of this question (i.e. sequence of objects after distribution) applies to all objects, not just pasted images.
Avatar of Jamie Garroch (MVP)
Jamie Garroch (MVP)
Flag of United Kingdom of Great Britain and Northern Ireland image

Try this VbA macro in a selection of shapes:

Sub DistributeSelectionHorizontally()
Dim sngLeft As Single, sngRight as Single
Dim oShp As Shape
sngLeft = ActivePresentation.PageSetup.SlideWidth
sngRight=0
' find left most and right most shapes
For Each oShp In ActiveWindow.Selection.ShapeRange
If oShp.Left < sngLeft Then sngLeft = oShp.Left
If oShp.Left + oShp.Width > sngRight Then sngRight = oShp.Left + oShp.Width
Next
' reposition the shapes within the space found above
Dim x As Long
Dim sngPos As Single
For x = 1 To ActiveWindow.Selection.ShapeRange.Count
' alternatively, count the other way
' For x = ActiveWindow.Selection.ShapeRange.Count To 1 Step -1
sngPos = (sngRight - sngLeft) / x 
oShp.Left = sngPos
Next
End Sub

Open in new window


It might need some tweaking when I'm back at a PC rather than typing blind on ab iPad!
ASKER CERTIFIED SOLUTION
Avatar of Jamie Garroch (MVP)
Jamie Garroch (MVP)
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial