I have an object created in memory using Microsoft.Office.Interop and Microsoft.Office.Word and with all created, paragraphs, tables and the like. I need this object to generate a content byte [] to feed one field of the same type in a table.
The problem that I can not save it in any way physically with a oDoc.Save (“path”) in order to use a FileStream and solve my problem.
Have tried several solutions and how to use the clipboard, and did not work. Any solution?
Do you really have to use the
Microsoft.Office.InteropandMicrosoft.Office.Word?If it is not really necessary, you could use the OpenXML SDK libraries for manipulating the content of the WordDocument.
OpenXML SDK contains a class
WordprocessingDocumentthat can manipulate a memory stream containing a WordDocument content. AndMemoryStreamcan be converted usingToArray()to abyte[].As a code sample: