Display the dimensions of a shape in real time

Hi All

Is it possible to use VBA to display the dimensions of a shape object in a cell in real time? For example, if a rectangle shape's width is currently 300 and I select it on the sheet and drag the width to 500, can I display the changing width in a cell?

Regards

Terry
TerrygordonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
Wayne Taylor (webtubbs)Commented:
No, there are no events that handle the changing shape.
0
 
TerrygordonAuthor Commented:
Hi Wayne

As it can't be done in real time, I have come up with a workaround that allows me to check the size and change it by clicking a button. It has to be clicked every time you want to see the dimensions of the object, but I don't think there is any alternative. The code is:

Sub Matlength2()

On Error GoTo ext
Wide1 = Range("B50").Value / 5
High1 = Range("B51").Value / 5
shptxt = Wide1 * 5 & " x " & High1 * 5
'MsgBox shptxt
Selection.ShapeRange.Height = High1
Selection.ShapeRange.Width = Wide1
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = shptxt
ext:

End Sub

Sub Currentsize()

On Error GoTo ext2
Wide1 = Selection.ShapeRange.Width * 5
High1 = Selection.ShapeRange.Height * 5
Range("f50").Value = Wide1
Range("f51").Value = High1
shptxt = Wide1 & " x " & High1
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = shptxt
ext2:

End Sub

Open in new window


Not sure what to do about points in this instance. Any suggestions?

Regards

Terry
0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
Wayne Taylor (webtubbs)Commented:
Question as asked was answered with the Asker providing an alternative.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.