Generate combobox

B

Beginner in vba

I m need to generate a few combobox in the userform. The number of combobox
generated is determine during the program runtime. How can i write my code in
the module to initialize how many combobox to generate in my userform. Thanks
alot.
 
H

Helmut Weber

Hi,

this generates 10 Comboxes in a row.

Dim l As Long
For l = 1 To 10
Selection.FormFields.Add _
Range:=Selection.Range, _
Type:=wdFieldFormDropDown
Next

The question rather is, where should they be placed?

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 
H

Helmut Weber

Oops,

for comboboxes on a userform you have to modify
the code a bit. The principle is:

Private Sub CommandButton1_Click()

Me.Controls.Add "Forms.Combobox.1", "Combo1"
Me.Controls("Combo1").Left = 50
Me.Controls("Combo1").top = 50

End Sub

The question is "where" and "what name" ?

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 

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