Freeform shapes area calculation

D

Dave Shaw

Hi

I would like users to be able to draw freeform shapes (using straight not
curved lines) and then to run a macro to calculate it's area in cm. I don't
mind if this is in Word 2003 or Excel 2007.

I have found some links on the web for excel methods but none of them seem
to work - I get overflow errors.

Any ideas

Thanks
 
D

Daniel Pineault

I have no clue if this can be done in access, but if you have some methods in
Excel that you need help with you should ask your question in the Excel
Forum. Provide them with a link and they'll be able to help.
 
H

Helmut Weber

Hi Dave,

Sub Test456()
Dim x As Double
Dim y As Double
x = PointsToCentimeters(Selection.ShapeRange(1).Height)
y = PointsToCentimeters(Selection.ShapeRange(1).Width)
MsgBox Format(x * y, "#.00 cm²")
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
D

Dave Shaw

Thanks for that but my problem is calculating freeform shapes - someone could
draw any shape with straight lines (star, random polygon, etc.) - so the
basic height x width does not work.

The concept to calculate I understand - the shape would need to be broken
down into triangles, the area of each triange calculated and then added
together. I can do this myself with a ruler and protractor - I'm just not
advanced enough at doing this using a macro - I'm rubbish at loops and never
really used VB for calculating angles and have no idea of how to split a
shape into triangles.
 
H

Helmut Weber

Hi Dave,

all I can do is point you in the hopefully right direction.
I never did something like that, at least not in Word,
which IMHO seems to be the worst possible application for that.

You got to access the nodes in the freeform,
and from the position of the nodes
you can start calculating areas.

See help on nodes property as it applies
to the shape and shaperange objects.
See help on points property,
as it applies to the shapenode object.

I'm sorry, I'm not the man who can help you
with a thesis in geometry, though I'd like to see
the algorithm, that does what you want.

Sure it is possible, every CAD-software does it just like that,
does even calculate volumes...

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top