使用宏从 Word 2007 中功能区的下拉列表中获取所选项目
我看到以下问题,它解释了如何从下拉列表中获取所选项目:-
http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/d1cf7b3e-68cf-4b82-b806-a3431acde3b6/
以上线程建议预先有一个项目的哈希表,将选定的 id 缓存在下拉列表的 onAction() 中,并使用该选定的 id 从按钮的 onAction() 中的哈希表中查找项目。
但是,就我而言,我从数据库填充功能区 XML。该功能区 XML 显然具有用于下拉菜单的 XML,并且我正在使用宏与下拉菜单和功能区中的其他控件进行交互。我不确定如何预先建立一个可供宏使用的集合,类似于上述线程中描述的方法。
I see the following question which explains how to get the selected item from the dropdown:-
http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/d1cf7b3e-68cf-4b82-b806-a3431acde3b6/
The above thread advises to have a hashtable of the items upfront, cache the selected id in the onAction() of the dropdown and use that selected id to find the item from the hashtable in the onAction() of the button.
BUT, in my case, I populate the ribbon XML from the database. This ribbon XML obviously has the XML for dropdown and I am useing macros to interact with the dropdown and other controls in the ribbon. I am not sure how to have a collection upfront which can be used by the macro similar to approach described in the above thread.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想提出解决方案,以防万一有人遇到同样的问题:-
这就是我的功能区下拉列表的样子:-
请注意 getItemLabel 和 onAction 的回调。有趣的是, getItemLabel 用于设置下拉菜单上的项目(通过下拉菜单获取)。这有点令人困惑,但这就是事实,这就是为什么我将我的方法命名为“SetTheSelectedItemInDropDown”。
onAction 的函数“GetTheSelectedItemInDropDown”用于获取所选项目。
现在以下是宏代码:-
就是这样,您现在应该能够设置和获取下拉菜单。
I wanted to put the solution just in case someone has the same problem:-
This is how my ribbon dropdown looks like :-
Note the callbacks for getItemLabel and onAction. Interestingly, getItemLabel is meant for setting the item on the dropdown (get by the dropdown). It is kinda confusing but thats the way it is and thats why I named my method as "SetTheSelectedItemInDropDown".
Function "GetTheSelectedItemInDropDown" for the onAction is to get the selected item.
Now following is the macro code:-
And thats it, you should be able to set and get the dropdown now.
下一个函数脚本适用于 Excel...
经过 2 小时的测试和谷歌搜索,我找到了一种改变和获取价值的方法。
1.)您必须有项目列表(序列),它们位于下拉列表中。
2.) 使用 .onaaction 和 application.caller 功能:(抱歉下一个脚本中的捷克语):
Next function script is for Excel...
after 2 hour testing and google searching, i´ve found a way how to change and get value.
1.) You must have list of items (sequence), witch are in dropdowns.
2.) use .onaaction and application.caller features: (sorry for czech language in next script):