none
ExportFragment issues RRS feed

  • Question

  • Hi Everyone,

    I have created a Word Add-in in C#. When the user selects any range in the word document and click on one button. I am using ExportFragment function to get the XML (document.xml contents) of that range. Then I load it to XML document and customize it.

    When I load the exported fragment content into a XML Document, I am getting all the contents including Paragraph and Run properties in this way:

    <w:p><w:pPr><w:pStyle w:val="Normal"/></w:pPr><w:r><w:rPr><w:i/><w:b/><w:rPr><w:t>This is a test Para</w:t></w:r></w:p>

    But in some of the Word documents, this ExportFragment doesn't export Run or paragraph properties. However, same content which has bold and italic content inside <w:rPr> in the document.xml is now coming as without rPr after doing ExportFragment call.

    <w:p><w:r><w:t>This is a test Para</w:t></w:r></w:p>

    Here is the code that I am using:

    mySelection.Range.ExportFragment(@"C:\MyFile.xml", Word.WdSaveFormat.wdFormatXMLDocument);

    Please let me know, what is stopping Word not to export these Run or Paragraph properties. I am using Word 2013.

    Thanks,


    Shahab Abbasi

    Tuesday, January 2, 2018 10:39 AM

All replies

  • Hi Shahab Uddin Abbasi,

    I try to make a test on my side.

    I did not get any issue with it.

    I try to export the content with bold and italic and when I check exported document.

    it has all the formatting.

    below is my testing result.

    it is better if you have any document that can reproduce the issue then please share with us with your sample project.

    we will try to make a test with it and try to reproduce the issue on our side.

    it will be helpful for us to provide you a solid suggestions to solve the issue.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, January 3, 2018 6:00 AM
    Moderator
  • Hi Deepak,

    I cant send the document as they are highly confidential documents. When I tried to send you the document by changing some of the contents, I started getting all the inline formatting. I am not sure, if this method has any dependency on size or changing the state of the document.

    I am still trying to modify the document for your testing. 

    Thanks,


    Shahab Abbasi

    Thursday, January 4, 2018 7:18 AM
  • Hi Shahab Uddin Abbasi,

    you had mentioned that,"I am still trying to modify the document for your testing".

    we don't require any confidential information.

    the document just should be able to reproduce the issue.

    so once you remove the confidential information you can share it with us.

    we will make a test with it.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, January 4, 2018 9:49 AM
    Moderator
  • Hi Deepak,

    After a long list of edits, I finally prepared the document for you. Please go to Table A6.1. Select the whole Table Range and export the Range with ExportFragment method we were discussing in this Question. Table A6.1 contains some columns with Bold formatting, but not exporting inline formatting using ExportFragment method.

    I have uploaded my test document on One drive at this location:

    https://ictect1-my.sharepoint.com/personal/lisa_jain_ictect_com/_layouts/15/guestaccess.aspx?docid=0c682576fed8d46949ca889a01a2a10b3&authkey=AbaDyx9_D8hnkLq4_NMSbTA&e=695a10e8fd374fb8941710d209e1c9ce

    Please download and check this document, and let me know your findings.

    Thanks,


    Shahab Abbasi

    Monday, January 8, 2018 10:31 AM
  • Hi Shahab Uddin Abbasi,

    I use your document and try to make a test with Word 2013.

    below is the output.

    you can see that Text has Bold and Italic formatting when I export it.

    let me know , if I miss any step to reproduce the issue.

    I will again try to make a test and let you know about the result.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, January 9, 2018 9:31 AM
    Moderator
  • Hi Deepak,

    Content you included is already working at my end. Please try to output the range of Table A6.1. Please see my last comment. Its contents looks problematic.

    Thanks,


    Shahab Abbasi

    Wednesday, January 10, 2018 5:56 AM
  • Hi Shahab Uddin Abbasi,

    i try to export the Table 6.1.

    i find that in Exported file the line is displayed on the previous page where as the same line displayed on the new page in original document.

    the reason can be that the original file get opened in compatibility mode and the new file is open in normal mode.

    other then that i did not find any difference.

    if this is not the difference that you are finding on your side then you can try to post the snapshot of difference from your side.

    we will try to check it and again try to provide you the suggestions.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, January 12, 2018 8:15 AM
    Moderator