none
Convert Range to FlowDocument and back RRS feed

  • Question

  • Hello,

     

    I am having some problems converting an Interop.Word.Range to a FlowDocument, and a FlowDocument to a Word.Range. I found something helpfull, the OpenXMLWriter, but it uses only files. And does only conversion from FlowDocument to Word.

     

    At the moment I am using the Clipboard as an intermediary and a RichTextBox. This is a very ugly way to do this. Does anyone have any ideas on how to do this elegantly?

     

    Best regards,

    Silviu.


    http://www.rosoftlab.net/
    Monday, August 22, 2011 6:42 AM

All replies

  • Hi Silviu,

    What do you mean about the FlowDocument? Do you mean the document show in WPF related controls? Please see this MSDN article:

    http://msdn.microsoft.com/en-us/library/aa970909.aspx#flow_document_types

    Best Regards,

     


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, August 25, 2011 8:58 AM
  • Hello,

     

    Yes, the documents shown in WPF controls. Your example is the same as the approach of the OpenXMLWriter. I was hoping to find something that would not need me to convert every single thing from Word to WPF and vice-versa.

     

    Best regards,

    Silviu.


    http://www.rosoftlab.net/
    Thursday, August 25, 2011 9:19 AM
  • Hi Silviu

    << I was hoping to find something that would not need me to convert every single thing from Word to WPF and vice-versa.>>

    There isn't anything like that in Word or Visual Studio. Conceivably, some third-party might make some kind of converter, but I've never heard of anything (yet).


    Cindy Meister, VSTO/Word MVP
    • Proposed as answer by Bruce Song Monday, September 5, 2011 11:31 AM
    Thursday, August 25, 2011 12:48 PM
    Moderator
  • Hi Silviu,

    I agree with Cindy. You may need to write the class library yourself to convert every single thing from word to WPF and it really involves plenty of tasks about the conversion. You can do some research about the OpenXMLWriter class and try to add more conversion about the marks.

    And here is a open source project about converting html to openxml and openxml to html, I think we can make use of the experience of them:

    http://notesforhtml2openxml.codeplex.com/

    http://openxmlviewer.codeplex.com/

    Hope this can give you the hint.

    Best Regards, 


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, August 29, 2011 10:08 AM