I'm having some trouble with a word add-in. I'm attempting to create a new document format, and have it sort-of working. The format is just an encoding on top of an existing docx. In other words, I can strip off the encoding and be left with a valid word document.
Saving:
Right now, when the user wants to save a document in the new format, I prompt to save the original, and then read the original from disk, saving a copy in the new format. This leaves 2 files on the filesystem (foo.docx and foo.myformat).
Ideally though, I'd like to intercept the document in the DocumentBeforeSave event, get the document as a byte array, transform it in memory, and just save a single copy. I can't seem to find a way to get the byte array however.
Opening:
Right now when the user selects a file to open that is stored in my format, I make a temporary copy (tmp\blah.docx), and then just open the document with Application.Documents.Open(tmp\blah.docx...).
I'd prefer instead to create the document from a memory stream, so I can avoid creating temporary files. Is it possible to create a new Word.Document from memory?
Any direction would be greatly appreciated. Thanks much.