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

4

1 に答える 1

1

Shapes クラスを使用して、形状の位置を取得できます (leftおよびtop)。右または下の位置が必要な場合は、leftandwidthまたはtopand を追加し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
于 2021-03-19T21:54:26.353 に答える