none
Knowing I'm in an embedded document RRS feed

  • Question

  • Hi all;

    To give a short bit of background, we have a reporting system where you design the report in Word. To do this the user puts tags in the document (think super-charged mail-merge). Our Add-In therefore needs to know where you are in a document and tags that came before that location.

    I want to handle an embedded document where I know that document B is embedded in document A and where it is embedded. So when the user is in document B, I can assist them with tagging taking into account tags in document A that exist before the embed point.

    This is for both the case:

    1. Where document is embedded as an OLE object and where it is just a document (not sure what to call this - the case where you see the Word icon, not a rendering of the document).
    2. And for both the case where document B is embedded in document A and where there is a link from document A to document B.

    The questions I have are:

    1. How do I identify the parent document?
    2. How do I get the location in the parent document of the embedded document?
    3. For an OLE object, how do I get what part of document B is rendered in document A?
    4. When document B is the active document, how do I access the Document object for document A?

    thanks - dave


    What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

    Thursday, August 10, 2017 3:40 PM

All replies

  • Hi DavidThi808,

    ->How do I identify the parent document?

    ->When document B is the active document, how do I access the Document object for document A?

    What do you mean parent document? Is it document A? Do you want to get Document A from document B? During testing, I found embedded documents would be open as name such as Document in DocumentA.docx. So as a workaround for embedded document, we could analysis its name to get its parent name.

    Just like

    Sub Test()

    parentName = Mid(ActiveDocument.Name, 13)

    Dim parentDoc As Document

    Set parentDoc = Application.Documents(parentName)

    End Sub

    However, I did not find any property which could return parent document for a linked document.

    ->How do I get the location in the parent document of the embedded document?

    I think there is no property of embedded document could reflect its location in its parent document. You could only get location of these embedded document for document A, via InlineShape.Range.

    ->For an OLE object, how do I get what part of document B is rendered in document A?

    As far as I know, inserting an OLE object will insert whole part of document B to document A, how did you insert part of document B to document? Could you share us your operation steps or related code so we could try to reproduce your issue.

    Best Regards,

    Terry

    Monday, August 14, 2017 1:49 AM