want to copy size of selected object to the clipboard (height & width seperated by , )using vba

i want to copy size (height & width) of selected object to microsoft excel

can some one give me the code for VBA

  • You can try code below:

    Sub copyobjectdata()
    Dim sh As ShapeRange, w#, h#
    ActiveDocument.Unit = cdrMillimeter
    Set sh = ActiveSelectionRange
    Set s = ActiveDocument.ActiveLayer.CreateParagraphText(1, 1, 0, 0, "")
    sh(1).GetSize w, h
    Set t = s.Text
    t.Story.InsertAfter(h & " , " & w).Copy
    s.Delete
    End Sub

    Another code export  information about objects on active page - object sequence on page, position x, position y, width, height - to file c:\corelobjects.txt

    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

    Hope this helps,

    Best regards,

    Mek