C microsoftofficeinteropworddocument to stream. Because it looks like all the interop does is open the word document. Create a simple windows application and place a button control in it. Dim strdoc as string cuserspublicdocumentsword13docx dim txt as string append text in body openandaddtowordprocessingstream dim stream as stream fileopenstrdoc filemodeopen openandaddtowordprocessingstreamstream txt streamclose. Yes but what are you needing to do with the stream.
Public static object deserializefromstreammemorystream stream iformatter formatter new binaryformatter. The document object is a member of the documents collection. Iformatter formatter new binaryformatter. C csharp microsoftofficeinteropword documentexportasfixedformat 4 examples found.
For int i 1. Document document applicationdocumentsopen cworddoc. Pinkfloydx33 jun 26 14 at 1038. Iformatter formatter new binaryformatter.
The documents collection contains all the document objects that are currently open in microsoft word. Public static object deserializefromstreammemorystream stream iformatter formatter new binaryformatter. Class program static void main open a doc file. If thats the case just open it with a files stream.
Object o formatterdeserializestream. Public static memorystream serializetostreamobject o memorystream stream new memorystream. Usedocumentsindex where index is the document name or index number to return a single document object. Loop through all words in the document.
Copy and paste the following code to generate the word document. Worddoc one two three c program that uses microsoft word interop using system. The index number represents the position of the document in the documents collection. Public static memorystream serializetostreamobject o memorystream stream new memorystream.
Application application new application. Double click the button control and go to the code widow. These are the top rated real world c csharp examples of microsoftofficeinteropworddocumentexportasfixedformat extracted from open source projects. Object o formatterdeserializestream.
You can rate examples to help us improve the quality of examples.