none
How to get InlineShape's ID or OLEobjects ObjectID in Word using VBA? RRS feed

  • Question

  • Is there any VBA call to return Inline Shape's ID or Embedded Objects Object ID in word?
    Friday, December 13, 2013 10:02 AM

Answers

  • Hi Basma

    VBA can do it if you're savvy enough to work with an XML Parser which you can access by adding a reference to your VBA project (to a version of MSXML, for example).

    The WordOpenXML property of a Range object will return the OPC flat file format of the Range. That should include the RELATIONSHIP information, as well as the XML you've shown me.

    It's probably going to be a child of the element <pkg:part
    pkg:name="/word/_rels/document.xml.rels"


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, December 17, 2013 2:44 PM
    Moderator

All replies

  • The InlineShape object has no ID property. And, since this is the case, no embedded OLE object that's managed by Word as an InlineShape will have this property.

    Cindy Meister, VSTO/Word MVP, my blog

    Friday, December 13, 2013 10:24 AM
    Moderator
  • I was trying to parse document.xml to get the name of the embedded OLE object as saved by word so that it can be retrieved from the Embeddings folder. If  there is no Id for inline shape how does one uniquely identify the XML node corresponding to that Inline shape? 
    Friday, December 13, 2013 12:06 PM
  • I haven't looked at the Word Open XML of an OLE object with that in mind, so I don't know if there might be something that will let you identify it. Discussions in this forum revolve mainly around the automation API. Post the xml code for an InlineShape and we can see what's there...

    Other than that, traditionally, we'd bookmark the object we need to "grab" using Automation.


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, December 13, 2013 3:22 PM
    Moderator
  • <o:OLEObject r:id="rId5" ObjectID="_1448701391" DrawAspect="Content" ShapeID="_x0000_i1025" ProgID="Excel.Sheet.12" Type="Embed"/>

    This is the XML code for an embedded excel file.

    Monday, December 16, 2013 6:49 AM
  • The attribute r:id="rId5" should give you the relationship, stored in the document.xml.rels file. You look up the relationship in the rels file in order to get the "path" to the embedded Excel object.

    Cindy Meister, VSTO/Word MVP, my blog

    Monday, December 16, 2013 4:23 PM
    Moderator
  • My purpose is to get rId5 so that I can get the path to the embedded object. Given the inlineshape and the XML file I need some way to retrieve the relationship Id and I thought that inlineshapeID or objectId can be of help but as you earlier mentioned there is no way of getting those through VBA.
    Tuesday, December 17, 2013 2:26 PM
  • Hi Basma

    VBA can do it if you're savvy enough to work with an XML Parser which you can access by adding a reference to your VBA project (to a version of MSXML, for example).

    The WordOpenXML property of a Range object will return the OPC flat file format of the Range. That should include the RELATIONSHIP information, as well as the XML you've shown me.

    It's probably going to be a child of the element <pkg:part
    pkg:name="/word/_rels/document.xml.rels"


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, December 17, 2013 2:44 PM
    Moderator