View Single Post
  #5  
Old 12-05-2010, 22:24
gorgo gorgo is offline
Senior Member
 
Join Date: Feb 2010
Posts: 169
Thumbs up

Quote:
Originally Posted by runflacruiser View Post
Hi.
This will be useful for me too. I have had this in my mind for sometime as an addon for one of my macros.

Code:
Option Explicit

Sub fitEmIn()

Dim s As Shape
Dim sr As ShapeRange
Dim i As Integer
Dim x#, y#, w#, h#
Dim x1#, y1#, w1#, h1#
Dim addup As Double
Dim space As Double
Dim itemsCount As Long
Dim boxLen As Double
Dim shapesLen As Double
Dim entry As Variant

entry = InputBox("Enter box width", "Fit em in!", 35)
If entry = "" Then Exit Sub
boxLen = entry

Set sr = ActiveSelectionRange
sr(1).GetBoundingBox x, y, w, h

For Each s In sr
    shapesLen = shapesLen + s.SizeWidth
Next s

space = (boxLen - shapesLen) / sr.Count
space = space + (space / sr.Count)

ActiveDocument.ReferencePoint = cdrBottomRight

addup = w
For i = 1 To sr.Count
    If i > 1 Then
        sr(i).GetBoundingBox x1, y1, w1, h1
        sr(i).SetPosition x + w1 + addup, y
        addup = addup + w1 + space
    Else
        sr(i).Move -space, 0
    End If
    
Next i

End Sub

-John
I feel silly again because I should have known how to properly use the align and dist tool which has been a feature in Draw for ages.
I was wrestling with it and just didn't use it correctly and so that's why I posted my question.
Now, Mr. John has some code to try and I did but I don't get how to apply this macro to my situation. I drew four rectangles and one large squarish rectangle which will be the container for these rectangles and ran your code and come up with weird results. There is a text box to enter a value but I'm not sure on the units it is using or even if it respects the current worldscale my document is set to. So, check this out when you can John and thanks again y'all.

-Greg (may just use the normal tool that Draw offers....until then)
Reply With Quote