Hi. If I wanted to draw four circles at .25" diameter and place them 1" from each center offset from a rectangle shape, how would I go about doing this in a macro?
see below sample
Here's something simple. I chose to position the circles relative to the active selection range .
Sub circles_off_corners() Dim sr As ShapeRange Dim sTemp As Shape Dim colorFill As Color Const dblOffset As Double = 1 Const dblDiameter As Double = 0.25 Set sr = ActiveSelectionRange If sr.Count > 0 Then Set colorFill = Application.CreateRGBColor(0, 0, 0) 'top left Set sTemp = ActiveLayer.CreateEllipse2(sr.LeftX - dblOffset, sr.TopY + dblOffset, dblDiameter / 2) sTemp.Outline.SetNoOutline sTemp.Fill.ApplyUniformFill colorFill 'bottom left Set sTemp = ActiveLayer.CreateEllipse2(sr.LeftX - dblOffset, sr.BottomY - dblOffset, dblDiameter / 2) sTemp.Outline.SetNoOutline sTemp.Fill.ApplyUniformFill colorFill 'top right Set sTemp = ActiveLayer.CreateEllipse2(sr.RightX + dblOffset, sr.TopY + dblOffset, dblDiameter / 2) sTemp.Outline.SetNoOutline sTemp.Fill.ApplyUniformFill colorFill 'bottom right Set sTemp = ActiveLayer.CreateEllipse2(sr.RightX + dblOffset, sr.BottomY - dblOffset, dblDiameter / 2) sTemp.Outline.SetNoOutline sTemp.Fill.ApplyUniformFill colorFill Else MsgBox "Nothing is selected.", vbExclamation, "Circles Off Corners" End If End Sub
There are lots of ways that could be improved, tweaked, made more bulletproof, made to work correctly if Document.Unit is something other than inches, made to detect if the active layer is locked, etc.
Outstanding. Thank you very much!