Welcome.
Is it possible to create a macro that will each time randomly change the order of selected objects?
For example, I have a group that is 160 mm long and consists of different rectangles and I'm looking for a way to randomly change their order on the x-axis while keeping the width of the whole group.
Thank you.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Sub arrange_left_to_right_random() Dim srOrig As ShapeRange Dim srNew As New ShapeRange Dim lngIndexOrig As Long Dim lngIndexNew As Long ActiveDocument.BeginCommandGroup "position_L_to_R_random" Set srOrig = ActiveSelectionRange While srOrig.Count > 0 lngIndexOrig = Int(Rnd() * (srOrig.Count) + 1) srNew.Add srOrig(lngIndexOrig) srOrig.Remove lngIndexOrig Wend srNew(1).PositionX = srNew.PositionX For lngIndexNew = 2 To srNew.Count srNew(lngIndexNew).PositionX = srNew(lngIndexNew - 1).PositionX + srNew(lngIndexNew - 1).SizeWidth Next lngIndexNew ActiveDocument.EndCommandGroup End Sub
.
VIDEO: Arrange Left to Right Random
Wooow, that's exactly what I needed :)
I am extremely grateful, Thank you Eskimo
Eskimo, I have noticed that sometimes macro behaves strangely, sometimes same objects in the new file do not align properly and I am not able to determine why.
Please look at the gif:
This can be related to the rotation of selected objects ....
Thx
Edit
The cause of the misbehaviour is most likely this macro:
http://www.gdgmacros.com/details.php?prodId=52&category=7&secondary=&keywords=
which I use to rotate objects.