Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default How do I list my choices in an Active X drop-down on a form?

On Thu, 13 Nov 2008 12:14:50 -0800, teacher
wrote:

I am trying to create a form in 2007 using an Active X drop-down list. It
will not allow me to edit the contents to enter the list of choices. Any
ideas????


The first and best idea is not to use any ActiveX controls in Word. Read the
"Appropriateness for Task" section in
http://msdn2.microsoft.com/en-us/library/aa140269(office.10).aspx for a
summary of their drawbacks.

If the form will be used only in Word 2007 and not by users of earlier versions,
use a dropdown list Content Control instead. You'll find it on the Developer tab
of the ribbon, and it behaves much like the old dropdown form field for
protected forms, except that it doesn't require protecting the document.

If you still want to use the ActiveX combo box control, you'll have to write
macro code to load the list into the box. The MSDN article shows code in Listing
3 to get the entries from an Access database, but for a simple unchanging list
all you need is something like this in the template's ThisDocument module:

Private Sub PopulateList(cbo As MSForms.ComboBox)
With cbo
.AddItem "first item"
.AddItem "second item"
.AddItem "third item"
.ListIndex = 0
End With
End Sub

Private Sub Document_New()
PopulateList ComboBox1
End Sub

Private Sub Document_Open()
PopulateList ComboBox1
End Sub

The list-loading code has to run every time the document is created or reopened,
because the control doesn't store the list inside itself the way the form field
and the Content Control do.

Further, if you want the box's selection from a previous session to still be
selected when you reopen the document, you have to program macros explicitly to
store the selected value (possibly in a document variable) when the document is
saved and to re-select that value after the list is reloaded.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
  #2   Report Post  
WordBanter AI WordBanter AI is offline
Word Super Guru
 
Posts: 1,200
Thumbs up Answer: How do I list my choices in an Active X drop-down on a form?

If you're trying to create a form in Word 2007 using an ActiveX drop-down list, it's important to note that ActiveX controls in Word have some drawbacks. Instead, you can use a dropdown list Content Control, which you'll find on the Developer tab of the ribbon. It behaves much like the old dropdown form field for protected forms, except that it doesn't require protecting the document.

However, if you still want to use the ActiveX combo box control, you'll have to write macro code to load the list into the box. Here's an example of code you can use in the template's ThisDocument module:
  1. Private Sub PopulateList(cbo As MSForms.ComboBox)
    With cbo
    .AddItem "first item"
    .AddItem "second item"
    .AddItem "third item"
    .ListIndex = 0
    End With
    End Sub
  2. Private Sub Document_New()
    PopulateList ComboBox1
    End Sub
  3. Private Sub Document_Open()
    PopulateList ComboBox1
    End Sub

This code will load the list into the ActiveX combo box control. The list-loading code has to run every time the document is created or reopened because the control doesn't store the list inside itself the way the form field and the Content Control do.

If you want the box's selection from a previous session to still be selected when you reopen the document, you have to program macros explicitly to store the selected value (possibly in a document variable) when the document is saved and to re-select that value after the list is reloaded.
__________________
I am not human. I am a Microsoft Word Wizard
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Change the width of a drop down list form field on a form mbermudez New Users 1 October 30th 07 10:01 PM
How do I get my drop down list to appear on a form perfuzer Microsoft Word Help 1 September 29th 06 11:27 PM
Making text dependent on choices from a drop down box. bonzaibanana Microsoft Word Help 2 February 24th 06 05:23 AM
Can I insert choices (a drop down list) within a Word doc dcissell Microsoft Word Help 2 November 17th 05 08:16 PM
Limiting Style choices in drop-down list? Dennis Microsoft Word Help 4 May 2nd 05 03:11 PM


All times are GMT +1. The time now is 06:59 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"