简体   繁体   English

获取当前文档的内容C#Word插件

[英]Get content of current document C# Word Addin

I would like to get the content of the currently opened Word document. 我想获取当前打开的Word文档的内容。 At the moment my code saves the document, closes it and then reads the file content. 目前,我的代码保存了文档,将其关闭,然后读取文件内容。 (Then converts to utf8 base64 for REST file upload) Is it possible to get the documents content without closing it? (然后转换为utf8 base64以进行REST文件上传)是否可以在不关闭文档内容的情况下获取文档内容? Could I also get the content as eg xml, because at the moment I can't open the document again after base64 decode. 我还可以将其内容获取为xml吗,因为目前在base64解码后无法再次打开文档。 (The document is defect, i think its converted wrong) (该文档有缺陷,我认为其转换错误)

得到了解决方案:

System.Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(Globals.ThisAddIn.Application.ActiveDocument.Content.get_XML()));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM