Dimensions of Shapes

Solved
duduleray -  
Patrice33740 Posted messages 8400 Registration date   Status Member Last intervention   -
Hello everyone, Forum hello,
<config>Windows 10 / Edge 81.0.416.68</Excel 2007>

I have inserted several shapes on my sheet 1, including a square and 5 rectangular shapes of different sizes.

I would like to know please where to find or how to calculate the dimensions of each shape.

Example: Rectangle 1 = ???

Top =
Left =
Width =
Height =

Thank you all for your help, have a good end of the afternoon.

Best regards, Dudu

4 answers

  1. Patrice33740 Posted messages 8400 Registration date   Status Member Last intervention   1 784
     
    Hello,

    Simply put:
    Sub test() Dim shp As Shape For Each shp In Worksheets("Sheet1").Shapes Debug.Print shp.Name, "T:" & shp.Top, "L:" & shp.Left, "W:" & shp.Width, "H:" & shp.Height Next shp End Sub


    Best regards
    Patrice

    No one can possess all knowledge, that's why we share it.
    1
  2. duduleray
     
    Hi Patrice 33740,

    Thank you for your reply and the little code.

    I have the code in a module, then on my Sheet1 I selected a shape and ran the macro

    but no result is displayed on the screen, could you please show the result in a MSGBOX with the name of the selected shape and of course the dimensions.

    For your information, each shape has a different name

    Thank you for your help, it's nice of you.

    Best regards, Dudu
    0
    1. Patrice33740 Posted messages 8400 Registration date   Status Member Last intervention   1 784
       
      My code lists all the shapes on the sheet and their dimensions in the VBE execution window.

      Here is a tutorial on the VBE and its windows: https://tutoriel-vba.espaceweb.usherbrooke.ca/vba_VBE.html
      When using a tool, you must start by learning how to use it.
      0
  3. duduleray
     
    Hi Le pivert, Patrice,

    Thank you for your remark, you are right, I apologize, I completely forgot the code you made for me.

    I haven't found it yet, but this time it's organized.

    Thanks again to both of you, and I'm sorry.

    Have a good evening and thanks again.

    I will therefore close the subject.

    Best regards, Dudu
    0