Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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:

properties

share|improve this question
    
Does it work if you right click and select properties rather than double click? –  CharlieRB Nov 22 '11 at 17:37
    
Updated question to show what happens when I select properties –  Kris C Nov 22 '11 at 20:03
add comment

1 Answer

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
add comment

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.