Drawing on a sheet through vB

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
 
G

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.
 
D

Dave Peterson

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.
 
D

Dave Peterson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top