none
Open xml relationship target is NULL when inserting chart RRS feed

All replies

  • Hi Peter

    This forum is not the ideal place for your question. Better would be the OPen XML SDK or the forum that covers the actual Open Office specifications. I can move it for you, but I'm not sure which is the better choice, based on what you've told us.

    Is your question more about how Word handles the Target attribute, or about inserting a diagram (Excel?) into a document?

    If the latter, my recommendation would be for you to create a simple document with such a diagram, then rename it with a Zip extension so that you can look at the internal files to see how Word wants to have it.

    That said, however, if you're using the Open XML SDK you do not need to worry about the Relationship file - the SDK takes care of that.


    Cindy Meister, VSTO/Word MVP, my blog

    Monday, March 9, 2015 5:58 PM
    Moderator
  • Hi Cindy,

    I'm actually trying to figure out what's going on under the hood since i have a small issue trying to parse a word document after invoking WordOpenXml property on an active word document. To be more specific, i'm trying to recreate the relationship but since the Target="NULL" i will not be able to create the Uri which should point to the inserted chart/diagram.

    So, i guess the Open XML forum is better suited for this kind of question? Would be great if you could move it to get a proper answer. :)

    Br,

    /Peter


    Peter

    Monday, March 9, 2015 9:44 PM
  • Hi Peter

    Ok, I will move it, but more it would help to have more information

    1. Repro steps, possibly with a sample of the starting document and desired result

    2. I recommend, however, that you first open these sample files in the Open XML SDK Productivity Tool. If you view a single document, you can look at code that generates it. You can also start with one document and "compare" it to another one in order to get the code to create the second from the first. This information might lead you to what you're missing :-)


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, March 10, 2015 6:48 PM
    Moderator
  • Hi Cindy,

    It is "easy" to reproduce :)

    1. Create a word document

    2. Add a CustomXml to the document with for example "Word content control toolkit"

    2:1 The CustomXml should look something like this <Root xmlns=http://schemas.company.se><Description></Description></Root>

    3. Open up the word document and open up the "XML Mapping Pane" under Developer tab. Add rich text content control which mapps to the <Description> element.

    4. Save and close the document

    5. Take a copy of thedocument

    6. Open up the document again, place the insert point within the content control mapped to <Description> element and insert a Chart.

    7. Save and close the document

    8. Rename the document with the extension .zip and navigate to word/charts/_rels/ and open up chart2.xml.rels.

    9. Search for Target="NULL", you should find 1 occurrence

    You can also download a sample here: http://1drv.ms/1raxoUr


    Br,
    /Peter


    Peter

    Wednesday, March 11, 2015 8:08 AM
  • Hi Peter

    Thank you for the detailed description. I believe the reason you're not finding this is because the information is stored in the Custom XML Part, linked to the content control. As far as Word is concerned, the chart isn't part of the document, only the content control is - what that brings in could be "anything", it's controlled by the CustomXMLPart. That's why the attribute TargetMode is set to "External" and why Target is Null.

    Your code that creates/modifies/manages the chart needs to work with the CustomXMLPart.


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, March 11, 2015 5:39 PM
    Moderator
  • Hi Cindy,

    Thanks for your thoughts on this.

    The strange thing is that other objects like images and stuff works without any problems at all. It's only diagrams that are causing problems.

    If i look into the open xml document stored within the CustomXmlPart(the xml stored in the <Description> element) i also see that Target="NULL" there as well. So, my thought on this that i could try to resolve the Target my self by looking into the directory /word/embeddings/ in order to create the target path. The problem here though is that i do not know which file to reference to(there could be many embedded files). Another thought is to look into the custom xml part as you said but the only reference to the chart i could find was charts/chart1.xml.
    The main question is, what should this relationship which is an oleObject point to?

    I'm also a bit concerned that i'm trying to resolve something that should be there in the first place.

    Could there be any other way that i could resolve the Target path?

    Br,

    /Peter


    Peter

    Thursday, March 12, 2015 10:04 AM
  • Hi Peter

    I think it would be best for you to ask about this in the Open specifications forum. Don't say anything about Open XML SDK, just focus on the problem with the Relationship Target. It should be fine to give them the link to the same sample file and provide the detail about the RT content control - I'm fairly certain that's what's causing what you're seeing, I just don't know what the logic is behind how Word's handling it.

    The people who monitor that forum are usually pretty good, although it can take some time for them to research. I'd offer to move the discussion, but they've asked me to not do that...

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=os_binaryfile

    I'd be interested in learning what they tell you!


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, March 12, 2015 7:50 PM
    Moderator
  • Hi Cindy,

    Okay, i will post a question at the open specification forum and we'll see what happens. Thanks!

    Br,

    /Peter


    Peter

    Friday, March 13, 2015 10:01 AM
  • Hi Cindy,

    A bit more information about this: I did a test with replacing null with an arbitary http address. So, i'm creating a relationship that points to a dummy address. It seems to work well. However, i need to know what is going on so we don't run in to some issues down the road.

    Br,

    /Peter


    Peter

    Friday, March 13, 2015 12:56 PM
  • Hi Peter

    Yes, I think you do still need input from the specs guys. One thing you should test, in any case, is how Word deals with your link when the document is edited and resaved and also if you go into Edit mode on the chart, then exit. Based on my experience with Word, generally, there's a real chance that Word could rewrite the OpenXML to match what it thinks is "right" (which is apparently the "NULL" value).


    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, March 14, 2015 9:06 PM
    Moderator
  • Hi Cindy,

    I got a reply from Matt with a bit more findings.

    An interesting thing he noticed was the fact that the chart placed inside the mapped rich text content control actually looses its data source. If you open up my "Doc with chart.docm" document and mark the chart within the rich text content control, then click on the Design tab. You will notice that the buttons within the "data" group are all grayed out. If this is a bug or a feature is the main question? In my opinion, a bug but i might not have all the facts :)

    Anyway, Matt recommended me to open up a support ticket to figure out what is going on.

    Br,

    /Peter


    Peter

    Tuesday, March 17, 2015 10:33 AM
  • Hi Peter

    Thank you very much for keeping me posted! And that is a very interesting bit of information, indeed. Almost certainly a bug in how Word integrates a chart into a RT content control, in that case.

    Have you happened to test whether it retains a value you right to the Target attribute or whether it overwrites it with NULL?


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, March 17, 2015 7:28 PM
    Moderator
  • Hi Cindy,

    Matt tested exactly that and he ended up with an error when opening the document in word saying that the document is corrupt.

    You can read more here:

    https://social.msdn.microsoft.com/Forums/en-US/b6ca722a-29a2-4ede-a306-286edc9a846c/open-xml-relationship-target-is-null-when-inserting-chart-into-a-mapped-rich-text-content-control-in?forum=os_binaryfile

    Br,

    /Peter


    Peter

    Friday, March 20, 2015 10:08 AM
  • Hi Peter

    Been busy and was going through my Inbox, where I found the alert for this...

    I'm curious: have there been any further developments?


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, May 28, 2015 8:48 PM
    Moderator