0

Dears;

I would like to thank you for your support. I'm in writing VBA macro to draw and color the shapes, I've got to step when I need to draw the shapes based on another position shapes, for that I need to know how I can know the shape position by its name thank you in advance

1 Answers1

1

You can use the Shapes class to get a shapes position (left and top). If you need their right or bottom position add left and width or top and height.

Sub GetShapePosition()
    Debug.Print "Left: " & ActiveSheet.Shapes("Oval 1").Left
    Debug.Print "Width: " & ActiveSheet.Shapes("Oval 1").Width
    Debug.Print "Right: " & ActiveSheet.Shapes("Oval 1").Left + ActiveSheet.Shapes("Oval 1").Width
    
    Debug.Print "Top: " & ActiveSheet.Shapes("Oval 1").Top
    Debug.Print "Height: " & ActiveSheet.Shapes("Oval 1").Height
    Debug.Print "Bottom: " & ActiveSheet.Shapes("Oval 1").Top + ActiveSheet.Shapes("Oval 1").Width
End Sub
pheeper
  • 1,457
  • 4
  • 20
  • 37