Macro question

Would it be possible to create a macro that looks at visible objects (and/or groups of objects) and resizes them automatically?  They would need to be either a specific height or width and never larger than either dimension.  For example - if the max height was .5" and the max width was 1" and if the partiicular object is enlarged to .5" tall and that makes it more than 1" wide then it would resize to the 1" width instead, and vice versa.  Hopefully this makes sense.

Parents
  • You can try following code

    Sub test()
    Dim s As Shape, wmax#, hmax#, sr As ShapeRange
    ActiveDocument.Unit = cdrMillimeter
    ActiveDocument.BeginCommandGroup ("test")
    Set sr = ActivePage.FindShapes.All
    For Each s In sr
    If s.SizeHeight > hmax Then hmax = s.SizeHeight
    If s.SizeWidth > wmax Then wmax = s.SizeWidth
    Next s
    For Each s In sr
    If s.SizeHeight / s.SizeWidth > 1 Then s.SetSize , hmax
    If s.SizeWidth > wmax Then s.SetSize wmax
    If s.SizeHeight / s.SizeWidth < 1 Then s.SetSize wmax
    Next s
    ActiveDocument.EndCommandGroup
    End Sub

    Best regards

    Mek

Reply Children