Is it possible to add an edit box or combo box to CommandBar["Text"] in Word?
I'm trying to add an edit box or combo box to one of the context menus when my Word add-in loads. But I haven't succeeded, and I don't get any errors, the edit/combo box just don't show up.
this.Application.CommandBars["Text"].Reset();
// add a menu to the context menu
CommandBarPopup subMenu = (CommandBarPopup)this.Application.CommandBars["Text"].Controls
.Add(Office.MsoControlType.msoControlPopup, missing, missing, 1, true);
subMenu.Caption = "My menu";
// add combo box to the newly created menu
CommandBarComboBox ctrl = (CommandBarComboBox)subMenu.Controls
.Add(MsoControlType.msoControlComboBox, missing开发者_运维知识库, missing, 1, true);
ctrl.Caption = "Bleh";
ctrl.Text = "Blah";
ctrl.AddItem("Hai", 1);
ctrl.AddItem("Hoi", 2);
ctrl.DropDownLines = 3;
ctrl.DropDownWidth = 75;
ctrl.ListIndex = 0;
ctrl.Visible = true;
The above code adds a menu to the right-click context menu in Word, called "My menu" and then I try to add a combo box to that menu, it doesn't show. The code is in my add-ins startup function.
Does anyone have any experience in this? is it even possible? or am I just doing something totaly wrong?
UPDATE
I guess there is some documentation about this out there somewhere. But I just can't seem to find it. This is the documentation that I've found:
http://msdn.microsoft.com/en-us/library/aa190799(v=office.10).aspx and from reading that, I get the impression that is should be possible to add CommandBarPopup, CommandBarComboBox and CommandBarButton.As far as I know, you can't place any "edit" control in a menu, you can only place them in a toolbar. Menus can contain spacers or MenuCommandButtons, or submenus, if I recall correctly.
精彩评论