Drawing on a sheet through vB

  • Thread starter Thread starter Gunti
  • Start date Start date
G

Gunti

Hi,
I recorded a macro creating two lines (to represent an X over a field)

ActiveSheet.Shapes.AddLine(31.5, 858.75, 607.5, 1077.75).Select
Selection.ShapeRange.Flip msoFlipVertical
ActiveSheet.Shapes.AddLine(30.75, 858.75, 607.5, 1077.75).Select

Basicly, i want to change this to something like this:

Worksheets("Invulblad").Shapes.AddLine(31.5, 858.75, 607.5, 1077.75)

How can i refer to the line to create the same effect (but not using .Select
and Selection.)?? Can i name my lines or objects??

PS. I drawed it through the drawing toolbox. If that matters.

Cheers.
Gunti
 
I'd like to simplify the question. How do i refer to a Shape to change it's
properties. I can probably figure out the properties by using the macro
recorder.
 
I'd try:

Dim myShape as shape

set myshape _
= Worksheets("Invulblad").Shapes.AddLine(31.5, 858.75, 607.5, 1077.75)

Then work with myShape.
 
By declaring the variable correctly (as a shape):

Dim myShape as Shape

You'll get VBA's intellisense to pop up each time you type:
myshape.
(that dot is important)

You'll be able to see the properties and methods.
 
Back
Top