Option Explicit
Public Sub measure_perimeter()
Dim doc As Document, old_units As Long
Dim sDupShape As Shape
Dim length As String, shape_count As Long
shape_count = ActiveSelection.Shapes.Count
If shape_count > 0 Then
'Set the document units to horizontal ruler units
Set doc = ActiveDocument
doc.BeginCommandGroup "IsoCalc.com's Perimeter temporary shapes"
old_units = doc.Unit
doc.Unit = doc.Rulers.HUnits
'Get the length of the shape or shapes and tidy up
ActiveSelection.Duplicate
ActiveSelection.UngroupAll
Set sDupShape = ActiveSelection.Combine
length = (sDupShape.Curve.length * doc.WorldScale) & " " + Choose(doc.Unit + 1, " tenth-microns", _
" inches", " feet", "mm", "cm", " pixels", " miles", "m", _
"km", " didots", " Agate", "yds", " pica", " cicero", "pt", _
"Q", "H")
doc.EndCommandGroup
doc.Undo
doc.Unit = old_units
'Report the length
If shape_count = 1 Then
InputBox "The perimeter is " & length & ".", "IsoCalc.com's Perimeter", length
Else
InputBox "The sum perimeter of all " & shape_count & " shapes is " & length & ".", _
"IsoCalc.com's Perimeter", length
End If
End If
End Sub