object position and size data export

Calling all CorelDrawers!,

I am generating a series of objects in coreldraw15 that I am placing into a single layer. I am interested in extracting their X,Y coordinates as well as height values into spreadsheet (.xls) format. Any thoughts on how I might do this?

Thanks!

  • You can try macro below, it creates file c:\corelobjects.txt with information about object on active layer. Mark “|“ (alt+0124) is used as delimiter. Txt file can be easily imported to Excel.

    sample txt file attached

     

    Sub objectdata()

    Dim sh As Shape, w#, h#, x#, y#, s As Shape, n#

    ActiveDocument.Unit = cdrMillimeter

    Set s = ActiveDocument.ActiveLayer.CreateParagraphText(1, 1, 0, 0, "pos|x|y|h|w" & vbCr)

    s.OrderToBack

    ActiveDocument.ReferencePoint = cdrCenter

    For Each sh In ActivePage.Shapes

    sh.GetPosition x, y

    sh.GetSize w, h

    i = sh.ZOrder

    Set t = s.Text

    t.Story.InsertAfter (i & "|" & x & "|" & y & "|" & w & "|" & h & "|" & vbCr)

    Next sh

    n = ActivePage.Shapes.Count

    t.ExportToFile "c:\corelobjects.txt", 1, n, cdrParagraphIndexing

    s.Delete

    End Sub

    corelobjects.txt
    pos|x|y|h|w
    1|200|120|10|10|
    2|180|120|10|10|
    3|160|120|10|10|
    4|140|120|10|10|
    5|120|120|10|10|
    6|100|120|10|10|
    7|80|120|10|10|
    8|60|120|10|10|
    9|40|120|10|10|
    10|20|120|10|10|
    11|88,2283|187,7593|34,2243|34,2243|
    12|0|115|14,023|14,023|