Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to follow the following instructions to add a combobox to a form and add some values to it for the user to pick: http://office.microsoft.com/en-gb/help/create-forms-that-users-complete-in-word-HP005230270.aspx

I've created a .dot and then dragged a combobox onto the document. When I double-click on it though, it opens up the VBA editor.

Do I have to add the items programatically as per the following question How do I add a combobox in Word? or is it possible to do this using the UI? The other question/answer refers to creating a form. Is there a step I've missed between creating a .dot to then create a form somehow before adding form elements to it?

Right clicking gives the following menu options:

  • Cut
  • Copy
  • Paste
  • properties
  • View code
  • Combo Box Object -> Edit or Convert
  • Format Control
  • Hyperlink

Choosing edit allows me to type some text onto the visible part of the control, but doesn't allow me to add multiple options

Right-clicking and selecting properties opens the following:

share|improve this question
up vote 1 down vote accepted

From the searching I've done so far, it appears this can only be done programatically (at least in older versions of Word).

e.g. http://oreilly.com/pub/a/oreilly/windows/ron/combodrop_0100.html

Your guess that you needed to add some code to populate your drop-down combo box is quite correct. VBA allows you to assign a value to the combo box's Value and Text properties (in reality, they're the same property) from the user interface, which lets you add only a single item to a drop-down combo box. This, of course, isn't terribly useful, since presumably you're using the combo box to allow the user to choose from among multiple items. This is precisely one of those quaint features of the MSForms controls--in Microsoft's retail Visual Basic product, it's very easy to populate a combo box at design time.

In almost all cases, you want to populate the combo box before the user sees it, so that the user can select from among the available items. Fortunately, Word makes this easy. Whenever a document opens, Word checks the code behind a Word document for the presence of a procedure named Document_Open. If it is found, the code is executed. (The procedure, incidentally, is called an event handler, since it's automatically executed by Word in response to some event, in this case the document's being opened by the user.)

VBA code now added and working, but somewhat surprised that there didn't appear to be a way to do this through the menus...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
{"cc_re__cc_re__cc_by_sa_3_0": ["                    <li><a href=\"//area51.stackexchange.com\" title=\"proposing new sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"//careers.stackoverflow.com\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2016 Stack Exchange Inc; user contributions licensed under <a href=\"https://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc by-sa 3.0</a> \r\n                with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2016.5.30.3623\r\n            </div>\r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Super User works best with JavaScript enabled<img src=\"http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif\" alt=\"\" class=\"dno\"></div>\r\n    </noscript>\r\n<script>va"], "copyright__copyright__copyright": [", is called an event handler, since it's automatically executed by Word in response to some event, in this case the document's being opened by the user.)\n\nVBA code now added and working, but somewhat surprised that there didn't appear to be a way to do this through the menus...\n\nshare|improve this answer\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}