Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Drop down choice changes next field options | Microsoft Word Help | |||
ComboBox Help | Microsoft Word Help | |||
Tools/Options choice insists on thinking for itself - help appreciated | New Users | |||
Limiting check box choices to only 1 choice | Tables | |||
combobox | Microsoft Word Help |