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?


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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

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

End Sub

Open in new window

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



Experts Exchange Solution brought to you by

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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.