Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Johanna Gronlund Johanna Gronlund is offline
external usenet poster
 
Posts: 4
Default Limiting choice to the options on combobox

Hello,

On my userform, I have a combobox that I have set up for my 49 items. The
code looks like this:

Private Sub ComboBox1_Change()
ActiveDocument.FormFields("Text1").Result = ComboBox1.Value
End Sub

Private Sub Cmdclose_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
ComboBox1.ColumnCount = 1
'Load data into ComboBox
ComboBox1.List() = Array("Option1", "Option2", "Option3", ..."Option49")
End Sub

At the moment, the users can select any of the options I have provided in my
combobox or type their own option. How can I limit their choice just to those
on the combobox? I have

Many thanks in advance,

Johanna
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Limiting choice to the options on combobox

Add this line to the UserForm_Initialize procedu

ComboBox1.MatchRequired = True

Equivalently, in the userform designer view in the VBA editor, click on the
combobox, go to the Properties pane (press F4 if it isn't visible), and set
the MatchRequired property to True there; then you don't need the line of
code.

According to the help topic on the MatchRequired property, "The user can
enter non-matching values, but may not leave the control until a matching
value is entered."

--
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.

Johanna Gronlund wrote:
Hello,

On my userform, I have a combobox that I have set up for my 49 items.
The code looks like this:

Private Sub ComboBox1_Change()
ActiveDocument.FormFields("Text1").Result = ComboBox1.Value
End Sub

Private Sub Cmdclose_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
ComboBox1.ColumnCount = 1
'Load data into ComboBox
ComboBox1.List() = Array("Option1", "Option2", "Option3",
..."Option49") End Sub

At the moment, the users can select any of the options I have
provided in my combobox or type their own option. How can I limit
their choice just to those on the combobox? I have

Many thanks in advance,

Johanna



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
Drop down choice changes next field options Cookness Microsoft Word Help 2 November 6th 07 01:23 AM
ComboBox Help Kenny Microsoft Word Help 1 September 22nd 07 01:32 AM
Tools/Options choice insists on thinking for itself - help appreciated Bert Coules New Users 7 September 12th 06 10:46 AM
Limiting check box choices to only 1 choice diana Tables 6 June 8th 05 11:37 AM
combobox Gman1959 Microsoft Word Help 1 January 27th 05 11:16 PM


All times are GMT +1. The time now is 04: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"