以编程方式选出遗产表格字段

发布于 2025-01-18 22:53:28 字数 308 浏览 3 评论 0原文

在 MS Word 版本 2202 (2019) 中,我的文档中有一个旧版表单字段(纯文本框),该字段在退出时进行计算,并使用计算结果填充许多其他字段。

我正在寻找一种使用 VBA 跳出该表单字段并触发计算的方法。换句话说,就像用户在表单字段中按下 Tab 键一样,退出该字段,并触发其他字段的计算和填充。

我已经尝试过以下代码:

Selection.TypeText Text:=vbTab

但它不起作用,因为除了填写表格之外,该文档被限制进行编辑。此限制禁止此代码模拟按 Tab 键。

谢谢。

In MS Word version 2202 (2019) I have a legacy form field (a plain text box) in a document that calculates on exit and fills a number of other fields with the result of calculations.

I'm looking for a way to use VBA to tab out of that form field and trigger the calculations. In other words, to function as if the user pressed the tab key when in the form field, exiting from the field, and triggering the calculations and filling of other fields.

I've tried the following code:

Selection.TypeText Text:=vbTab

but it doesn't work because the document is restricted from editing -- other than filling forms. This restriction prohibits this code from emulating pressing the tab key.

Thanks.

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

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

发布评论

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

评论(1

所有深爱都是秘密 2025-01-25 22:53:28

编辑该字段后所需的只是:

ActiveDocument.Fields.Update

All you need after editing the field is:

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