Serialize current ActiveDocument from office 2007 add-in

扶醉桌前 提交于 2019-11-28 12:46:09

You can convert ActiveDocument to the COM interop IPersistFile to save a copy of the open documents' bytes to a local temp path and then read them back in for sending to your webservice. In Office, you cannot read the bytes from the active document without first saving to disk. See this MSDN blog for reference.

COM.IPersistFile compoundDocument = Application.ActiveDocument as COM.IPersistFile; 
compoundDocument.Save(filePath, false);
byte[] content = File.ReadAllBytes(filePath);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!