FormFields Drop-Down

B

Bonnie

Can you add more that 25 items to a drop down list in VBA?
if so, what is the code to add the drop down list box and
the items?

By just using the DropDown form field options dialog box
it will only let me enter in 25 items

Thank you
 
J

JGM

Hi Bonnie,

Create a userform with a combobox called, originally enough, ComboBox1.
Then copy the following code in the userform code page:
'_______________________________________
Private Sub ComboBox1_Change()

ActiveDocument.FormFields("Text1").Result = ComboBox1.Value

End Sub
'_______________________________________
Private Sub CommandButton1_Click()

Unload Me

End Sub
'_______________________________________
Private Sub UserForm_Initialize()

ComboBox1.ColumnCount = 1

'Load data into ComboBox
Dim myArray(1 To 50) As String
Dim i As Integer

For i = 1 To 50
myArray(i) = "Item # " & i
Next i

ComboBox1.List() = myArray

End Sub
'_______________________________________

Then insert a standard module and paste the following proccedure in it:
'_______________________________________
Sub gocombobox()

frmcombo.Show

End Sub
'_______________________________________

Finally, insert a dropdown form field control in your form and add the
"gocombobox" macro to the "On entry" event of the dropdown field
(Properties...)

Of course ytou will have to put your own stuff in the combobox, if you are
not familiar with it, look for the help topic on List or AddItem in the
MicrosoftForm help.

HTH
Cheers!
 
B

Bonnie

THANK YOU
-----Original Message-----
Hi Bonnie,

Create a userform with a combobox called, originally enough, ComboBox1.
Then copy the following code in the userform code page:
'_______________________________________
Private Sub ComboBox1_Change()

ActiveDocument.FormFields("Text1").Result = ComboBox1.Value

End Sub
'_______________________________________
Private Sub CommandButton1_Click()

Unload Me

End Sub
'_______________________________________
Private Sub UserForm_Initialize()

ComboBox1.ColumnCount = 1

'Load data into ComboBox
Dim myArray(1 To 50) As String
Dim i As Integer

For i = 1 To 50
myArray(i) = "Item # " & i
Next i

ComboBox1.List() = myArray

End Sub
'_______________________________________

Then insert a standard module and paste the following proccedure in it:
'_______________________________________
Sub gocombobox()

frmcombo.Show

End Sub
'_______________________________________

Finally, insert a dropdown form field control in your form and add the
"gocombobox" macro to the "On entry" event of the dropdown field
(Properties...)

Of course ytou will have to put your own stuff in the combobox, if you are
not familiar with it, look for the help topic on List or AddItem in the
MicrosoftForm help.

HTH
Cheers!
--
_______________________________________
Jean-Guy Marcil
(e-mail address removed)

"Bonnie" <[email protected]> a écrit dans le message de



.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top