Determining the length of a curve in Corel Draw 11


When designing in Corel Draw, it can be very useful to know the total length of a curve. Since the curve may consist of straight and curved sections, this is not trivial, and unfortunately the user interface doesn’t help you here – it only tells you the width and height of an object.

So in order to get that length, use this Visual Basic macro:

Sub getLineLen()
 Dim sel As Shape
 Set sel = Application.ActiveDocument.ActiveShape
 Dim l, sl As Double
 Dim seg As Segment
 Dim prevu As cdrUnit

 prevu = Application.ActiveDocument.Unit
 Application.ActiveDocument.Unit = cdrMillimeter

 For Each seg In sel.Curve.Segments
 sl = seg.Length
 l = l + sl
 Next seg
 MsgBox ("Length: " & l)

 Application.ActiveDocument.Unit = prevu
End Sub

This should work in other versions of Corel Draw, too, but I could verify that for version 11 only. In order to make this work, go to the menu item “Tools -> Visual Basic -> Visual Basic editor…”. Click on “GlobalMacros”, then on “Module” and “CorelMacros”. Paste the code at the bottom of this text file. Then click on File -> Save.

To use the macro, select the relevant curve, then click on “Tools -> Visual Basic -> Execute…”. Select the macro from the list (select “Macros in” “all standard projects”) and click on “Execute”. The length of the curve will appear in a small message box.

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. For more details on what you can and cannot do with my work, see here.


  1. Jeff Osborne,

    Getting an error when I run it. When I debug, this line highlights in yellow. Any ideas?
    For Each seg In sel.Curve.Segments

    1. Jeff Osborne,

      I had it working once. Then once I switched the code as per the comment in here, it started giving me an error…

    2. admin,

      Sorry for the late reply! I had been very busy in the past few days. As for the error, what is the exact error message? And which CorelDraw version do you use? The most likely problem is that your selection includes at least one object that isn’t a curve, e.g. a bitmap, text. Another problem might be if a selected object has some non-trivial modification such as a drop-shadow, a lense effect, etc.

      I would try to test the code with a very simple shape such as a rectangle in a freshly created, empty document.

      Very importantly, please note that the macro only works with curves (when the object is selected, in the status bar it should say ‘Curve’, not ‘Rectangle’, ‘Ellipse’, etc). The standard shapes such as ellipses and rectangles need to first be converted to curves (by pressing CTRL+Q).

  2. Prashant,

    Very helpful!!! Thanks a lot!!!!!
    but how can change unit mm to inches?

    1. admin,

      Just change this line

      Application.ActiveDocument.Unit = cdrMillimeter


      Application.ActiveDocument.Unit = cdrInch

  3. Becs,

    ‘Paste the code at the bottom of this text file.’
    What is the code you mention? I can’t see it.
    Many thanks!

    1. admin,

      It’s the text set in the monospaced font above, everything from “Sub getLineLen()” to “End Sub”. Copy this text and paste it into the Visual Basic editor.

Comments are closed.