如何在运行时向 Word 文档添加 Bookmark 控件

发布于 2024-09-28 09:42:36 字数 256 浏览 0 评论 0原文

我想在 C# 应用程序中在运行时将书签添加到我的 Word 文档的特定范围。我找到了一种解决方案 Microsoft.Office.Tools.Word.Bookmark bookmark1; bookmark1 = this.Controls.AddBookmark(this.Paragraphs[1].Range, "bookmark1");

但错误表明 Windows 窗体没有 AddBookmark 的定义。请帮忙。

I want to add in a C# application a bookmark to a particular range to my Word document at runtime . I have found one solution
Microsoft.Office.Tools.Word.Bookmark bookmark1;
bookmark1 = this.Controls.AddBookmark(this.Paragraphs[1].Range, "bookmark1");

But an error shows that the Windows form has no definition for AddBookmark. Please help.

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

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

发布评论

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

评论(1

佼人 2024-10-05 09:42:36

您正在使用 WinForms 应用程序,因此通过使用关键字 this 它将引用您正在使用的表单类,该类没有 Controls.AddBookmark 的定义。

我建议您看一下这里: ​​http://msdn.microsoft.com/en -us/library/cc442946.aspx

这将向您展示如何创建一个单词插件,然后您可以使用此代码添加书签。

Microsoft.Office.Tools.Word.Bookmark bookmark1; bookmark1 = this.Controls.AddBookmark(this.Paragraphs[1].Range, "bookmark1");

You are using a WinForms application, therefore by using the keyword this it will refer to the form class you are using which does not have a definition for Controls.AddBookmark.

I suggest you take a look here: http://msdn.microsoft.com/en-us/library/cc442946.aspx

This will show you how to create a word addin from which you can then use this code to add a bookmark.

Microsoft.Office.Tools.Word.Bookmark bookmark1; bookmark1 = this.Controls.AddBookmark(this.Paragraphs[1].Range, "bookmark1");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文