从 Office 功能区代码访问文档流

发布于 2024-08-13 12:31:33 字数 175 浏览 4 评论 0原文

我正在尝试为 Microsoft Word 2007 编写一个加载项。我想创建一个功能区按钮,单击该按钮时,会获取当前或活动文档的 FileStream。我认为使用 Visual Studio Tools for Office 可以实现这一点。有谁有任何示例代码可以展示如何执行此操作?

如果您有任何疑问,请告诉我。谢谢

I am attempting to write an add-in for Microsoft Word 2007. I'd like to create a Ribbon Button that when clicked, gets a FileStream for the current or active document. I would assume that is possible with the Visual Studio Tools for Office. Does anyone have any sample code that would show how to do this?

Let me know if you have any questions. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

盗心人 2024-08-20 12:31:33

在功能区按钮代码上尝试一下(对于文档级加载项):

string document = Globals.ThisDocument.Application.ActiveDocument.FullName;

然后在 MSDN

*如果存在未保存的更改,可能需要先提示或强制保存。

Try this out on the ribbon button code (for document-level add-ins):

string document = Globals.ThisDocument.Application.ActiveDocument.FullName;

Then use the standard example for FileStream.Read on MSDN

*Might need to prompt or force a save first, if unsaved changes exist.

晨曦÷微暖 2024-08-20 12:31:33

另一种方法可能是使用 .WordOpenXML 获取打开文档的 XML 表示形式,

这将是当前状态(即包括未保存的更改)。

Another approach might be to get the XML representation of the open document, using .WordOpenXML

That will be the current state (ie including unsaved changes).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文