如何获取 Microsoft Word 中下拉菜单的值
我有一个 Microsft Word 文档,其中有一个下拉菜单。 我正在尝试编写一个宏来获取下拉列表的值并执行计算。 如何获取下拉菜单的值?
I have a Microsft Word document with a drop-down menu in it. I am trying to write a macro that gets the value of the drop down and performs calculations. How do I get the value of the drop-down?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您可以通过您指定的名称(“属性”框中的“书签”字段)或您添加的字段序列中的编号来获取对下拉列表的引用。
然后使用 Result 属性显示当前选定的值。
我创建了一个空白文档,上面有两个下拉列表(显示“表单”工具栏,然后单击一个按钮以在光标位置插入该控件):
然后我编写了一些测试例程:
这些是来自“立即”的 ListDropDowns 和 ShowChosenColor 的结果窗口:
更多立即窗口测试:
First, you can get a reference to the dropdown either by the name you gave it (the Bookmark field in the Properties box), or by its number in the sequence of fields you added.
Then you use the Result property to show the currently selected value.
I created a blank document with two dropdown lists on it (show the Forms toolbar, then click a button to insert that control at the cursor position):
then I wrote a few test routines:
these are the results of ListDropDowns and ShowChosenColor from the Immediate window:
some more Immediate window test: