none
Best way to Serialize/Deserialize a word document? RRS feed

  • Question

  • within an office add-in for word what is the best way to serialize/Deserialize a document ?

    Currently I'm using WordDocument.SaveAs and Word.Application.Documents.Open to save the document out to a file first and to load from a file but this is quite clunky. is it possible to serialize/deserialize a word document entirely in memory ?

    Ideally i'd have a solution that works for versions of word 2007 onwards.

    Regards

    -John


    Saturday, November 1, 2014 5:15 PM

Answers

  • Hello John,

    The Word object model doesn't provide any property or method for reading/writing a file from memory streams. You need to use the Save/SaveAs and Open methods for getting documents serialized/deserialized. What exactly do you need implement in the add-in? 

    You may find the Open XML SDK as an alternative way to work with Word documents.

    Sunday, November 2, 2014 12:46 PM

All replies

  • Hello John,

    The Word object model doesn't provide any property or method for reading/writing a file from memory streams. You need to use the Save/SaveAs and Open methods for getting documents serialized/deserialized. What exactly do you need implement in the add-in? 

    You may find the Open XML SDK as an alternative way to work with Word documents.

    Sunday, November 2, 2014 12:46 PM
  •  What exactly do you need implement in the add-in? 

    You may find the Open XML SDK as an alternative way to work with Word documents.

    Hi ,

    Thanks for pointing me in the direction of Open XML SDK, i'll look into that.

    the add-in is essentially a internal tool for document management & collaboration. End users don't need/or want to know where the document lives, and don't particularly need/want to see a file on their local file system. For example if I use the Open method it adds an entry to the "Recents" list pointing to the local temp file. i'd rather avoid this klunkyness. 


    Saturday, November 8, 2014 3:11 PM
  • Hi John,

    Please check this document for how to open the word from the stream:

    How to: Open a word processing document from a stream (Open XML SDK)

    I temporarily mark Eugene's reply as answer, if you come back and find that it's not what you want, please unmark it and follow up.

    Thanks for your understanding.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, November 17, 2014 1:28 AM
    Moderator