Drawing and Placing Shapes

dgrimm

Board Regular
Joined
Sep 17, 2007
Messages
159
I am creating a report that I am creating buttons (shapes) and attaching macros to the shapes to move around the report.

This is what I am needing help on.

I want to create a rounded rectangle and lets say size = 1" by 3" with the text "Goto Help Screen" placed in the upper left of cell "K7" with a red color.

Thank you

Dave
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Record a macro and the draw the shape this will then give you the code you need.
 
Upvote 0
I have tried to record the drawing of the shape but all the recording gives me is the cell that I select.

Thanks though.

Dave
 
Upvote 0
You can get some help for the VBA Help system, I didn't realise that when recording shapes it doesn't record the code. Sorry Dave I seemed to miss lead you here.

Here is a basic code that it comes up with. It will get you going.

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> Macro3()<br><SPAN style="color:#00007F">Set</SPAN> myDocument = Worksheets(1)<br>myDocument.Shapes.AddShape msoShapeRectangle, 50, 50, 100, 200<br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0
Just created this.

Sub ashape()
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 72, 72, 72, 72).Select
With Selection
.Characters.Text = "Help File"
.ShapeRange.Fill.Visible = msoTrue
.ShapeRange.Fill.ForeColor.SchemeColor = 2
.ShapeRange.Line.Visible = msoTrue
.ShapeRange.Line.ForeColor.SchemeColor = 64
.ShapeRange.Line.BackColor.RGB = RGB(0, 255, 0)
.Name = "Prepared_by_box"
'.OnAction = "eng_design_box"
.Top = Range("k5").Top
.Left = Range("k5").Left
End With
End Sub
 
Upvote 0
Trevor thank you for all the help thus far....I am needing one more thing.

Could you help on making it a beveled rounded rectangle.

Thank you
 
Upvote 0
Im not totally convinced you can do this, but this will give you a bevel shape.

Sub ashape()
ActiveSheet.Shapes.AddShape(msoShapeBevel, 72, 72, 72, 72).Select
With Selection
.Characters.Text = "Help File"
.ShapeRange.Fill.Visible = msoTrue
.ShapeRange.Fill.ForeColor.SchemeColor = 2
.ShapeRange.Line.Visible = msoTrue
.ShapeRange.Line.ForeColor.SchemeColor = 64
.ShapeRange.Line.BackColor.RGB = RGB(0, 255, 0)
.Name = "Prepared_by_box"
.OnAction = "eng_design_box"
.Top = Range("k5").Top
.Left = Range("k5").Left
End With
End Sub

Also here is a link that will list the msoShapes you can use.
http://msdn.microsoft.com/en-us/library/aa432469(v=office.12).aspx
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,845
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top