OpenXML - 限制自定义 MS-Word 功能区中组中显示的按钮数量
我想限制 Word 2007 中功能区组中的按钮数量,因为按钮是根据数据库中的数据生成的。请参阅下图。 。我希望功能区中的数量有限,例如 6 个左右,并带有一个对话框启动器,单击该启动器将打开一个显示所有按钮的窗格。有没有办法做同样的事情。有人还可以告诉我当有人单击对话框启动器时如何创建该窗格吗?
I want to limit the number of buttons in the group of a ribbon in Word 2007 as the buttons are getting generated on the basis of data in the database. See the pic below. . I wanted to have limited number, say 6 or so in the ribbon with a dialogboxlauncher which when clicked will open a pane showing all the buttons. Is there any way of doing the same. Can somebody also tell me how to create that pane when somebody clicks on the dialogbox launcher?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的方法是将功能区中的一些(例如 6 个)项目作为按钮加载,并将所有项目添加为文档中的 CustomXMlPart。在文档中,我添加了一个包含列表框的用户控件。在功能区加载中,我从 CustomXmlPart 获取所有项目并将它们放入列表框中。在对话框启动器按钮上单击,我显示/隐藏用户控件以显示列表中的所有项目。
以下是详细步骤:-
a) 从数据库中获取所有项目并将其保留在集合中。
b) 使用上述集合中的 6 个按钮生成如下所示的功能区 XML:-
c) 将集合作为 CustomXMLPart 添加到文档中:-
d) 转到 docm 文件的开发人员选项卡,将 UserForm 添加到项目中并向其添加一个列表框。编写一个子例程,该子例程将加载已添加到文档中的 CustomXMlPart 中的项目,并将这些项目添加到用户窗体中的列表框中。如下所示:-
e) 定义名为 RibbonLoad 的子项,该子项从功能区的 onLoad 事件中调用(检查 RibbonXML)。从此 RibbonLoad 子程序调用 LoadItems 子程序。
f) 定义以下子控件,它将显示/隐藏用户控件。这是在dialogBoxLauncher 按钮的onAction 上调用的。 (请参阅 RibbonXML)
The way I did it is to load some (say 6) of the items in the ribbon as buttons and add all the items as the CustomXMlPart in the document. In the document, I added a user control which contained a listbox. On the ribbon load, I get all the items from the CustomXmlPart and put them in the listbox. On the dialogbox launcher button click, I show/hide the user control to show all the items in the list.
Following are the steps in detail :-
a) Get all the items from the database and keep that in collection.
b) Generate the ribbon XML like the following withe the 6 buttons from the above collection :-
c) Add the collection as the CustomXMLPart to the document :-
d) Go to the developer tab of your docm file, add a UserForm to the project and add a listbox to it. Write a subroutine which would load the items from the CustomXMlPart added already to the document and add those items to the listbox in the userform. Something like below :-
e) Define the sub named RibbonLoad which is called from the onLoad event of the ribbon (check the RibbonXML). Call the LoadItems sub from this RibbonLoad sub.
f) Define the following sub which will show/hide the user control. This is called on the onAction of the dialogBoxLauncher button. (see the RibbonXML)