Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record macros with shapes 2

Status
Not open for further replies.

ciy

Electrical
Jul 7, 2009
53
I would like to record macros with shapes.
When I done the shapes (eg. Two circles to form a transformer symbol), then group them as finish.
Next time I want to get the transformer symbol in group, just pick the dedicated macro up.
But, the work isn’t so smooth expectedly.
The said macro can’t run completely when I repeat to run macro.
Something wrongs in it that I can’t fix by myself.
Please refer to the attached and give me a hand.
Thanks in advance.
 
Replies continue below

Recommended for you

If you give the shapes a new name after you have created them, you can then select and group them:

ActiveSheet.Shapes.AddShape(msoShapeOval, 174, 85.5, 60, 57).Select
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset7
Selection.ShapeRange.Name = "NewOval1"
ActiveSheet.Shapes.AddShape(msoShapeOval, 174.75, 106.5, 60.75, 64.5).Select
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset7
Selection.ShapeRange.Fill.Visible = msoFalse
Selection.ShapeRange.Name = "NewOval2"
ActiveSheet.Shapes.Range(Array("NewOval1", "NewOval2")).Select
Selection.ShapeRange.Group.Select

This code only allows one copy of the new shape, and it will always be created in the same place on the sheet, but it may be enough to get you started.

Doug Jenkins
Interactive Design Services
 
IDS,

Thanks for your valuable reply.
Now, the macro running is smooth and correct.

Best regards,

CIY
 
IDS,

Your recommendation is enough to me.
However, I wonder how to create new shape without limitation of only copy.
Your advice shall be appreciated.
Thanks again.

CIY
 
For i = 1 To 10
ActiveSheet.Shapes.AddShape _
(msoShapeOval, 174 + 10 * i, 85.5, 60, 57).Select
Selection.ShapeRange.Name = "NewOval" & "(" & i & ")"
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset7
Next i


Only put off until tomorrow what you are willing to die having left undone. - Pablo Picasso
 
BigInch,

Thanks for your advice!

CIY
 
you're welcome. There may be more elegant ways to do it, but ... that one works.

Only put off until tomorrow what you are willing to die having left undone. - Pablo Picasso
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor