ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to draw a object and erase it programmatically (https://www.excelbanter.com/excel-programming/298308-how-draw-object-erase-programmatically.html)

Simon Lenn

How to draw a object and erase it programmatically
 
I want to draw a rectangle with a circle programmatically and then I
want to erase and draw the rectangle and circle at a different place
on the worksheet.

Appreciate if somebody can share the code segment for a routine for
this.

Thanks
Simon

Lady Layla

How to draw a object and erase it programmatically
 
Take a test sheet, start recording macro, do what you are trying to do, stop
recording, read the code


"Simon Lenn" wrote in message
om...
: I want to draw a rectangle with a circle programmatically and then I
: want to erase and draw the rectangle and circle at a different place
: on the worksheet.
:
: Appreciate if somebody can share the code segment for a routine for
: this.
:
: Thanks
: Simon



Bob Phillips[_6_]

How to draw a object and erase it programmatically
 
Sim on,

The macro recorder gives it

Dim myshape As Shape

Set myshape = ActiveSheet.Shapes.AddShape(msoShapeRectangle, 165#,
255.75, 192.75, 91.5)
myshape.Name = "My Rectangle"
Set myshape = ActiveSheet.Shapes.AddShape(msoShapeOval, 436.5, 333#,
67.5, 66.75)
myshape.Name = "My Circle"

and

With ActiveSheet
.Shapes("My Rectangle").Delete
.Shapes("My Circle").Delete
End With


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Simon Lenn" wrote in message
om...
I want to draw a rectangle with a circle programmatically and then I
want to erase and draw the rectangle and circle at a different place
on the worksheet.

Appreciate if somebody can share the code segment for a routine for
this.

Thanks
Simon




Dave Peterson[_3_]

How to draw a object and erase it programmatically
 
You may want to group the circle and rectangle and instead of deleting, just
move them.

You could even add them multiple times and then toggle the visibility.



Simon Lenn wrote:

I want to draw a rectangle with a circle programmatically and then I
want to erase and draw the rectangle and circle at a different place
on the worksheet.

Appreciate if somebody can share the code segment for a routine for
this.

Thanks
Simon


--

Dave Peterson



All times are GMT +1. The time now is 01:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com