如何以编程方式检查 MS Word 2007 文档的任何文档属性是否已更改?

发布于 2024-07-27 15:59:28 字数 279 浏览 2 评论 0原文

例如,我希望每当文档属性面板中的标题字段发生更改时,文档正文中的标题字段和页眉都会自动更新。 我知道如何更新字段,但我想知道事件的名称,该事件将告诉我文档属性何时发生更改。

我们将不胜感激您的帮助。 谢谢。

我还在 MSDN 上询问过论坛

For example, I want the Title fields in the body and the page headers of the document to be updated automatically whenever the Title field in the document properties panel is changed. I know how to update the fields, but I want to know the name of the event that will tell me when the document properties have changed.

Your help will be appreciated. Thanks.

I also asked it on the MSDN Forums.

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

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

发布评论

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

评论(2

|煩躁 2024-08-03 15:59:29

Word 没有任何类似的事件。 您能做的最好的事情就是使用选择更改事件,这会经常发生,但是您必须检查所有文档的所有属性。

我认为您正在尝试执行 Word 通常不会执行的操作。 有时字段会更新,仅此而已。 教您用户它是如何工作的。

Word doesn't have any events like that. The best you might be able to do is use the selection change event, which will happen fairly often, but then you have to check all the propertiers of all the documents.

I think you're trying to do something that Word doesn't normally do. There are certain times when fields are updated and that's it. Teach you users how it works.

回心转意 2024-08-03 15:59:28

您当然可以在某些事件中检查此类内容,例如 DocumentBeforeCloseWindowSelectionChange,但这可能有点过头了。 相反,您可以只使用字段 - 它们会自动更新。 例如,转到插入,然后单击快速部件,然后单击字段...转到文档信息 > 左侧下拉列表中的部分,然后选择标题。 然后,插入它并返回到功能区上的“主页”选项卡,并将其样式设置为标题

您还提到您还需要页眉 - 是您在文档面板中设置的那些属性吗?

You can certainly check for these kinds of things in some of the events, such as DocumentBeforeClose or WindowSelectionChange, but this may be overkill. Instead, you could just use fields - they will update automatically. For example, go to Insert and then click on Quick Parts and then Field... Go to the Document Information section in the dropdown on the left and choose Title. Then, insert that and go back to the Home tab on the Ribbon and set its style to Title.

You also mention you also want page headers - are those properties you're setting in the Document Panel?

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