can any one point me in the right direction on how to create a drop down list with say 6 x items
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
drop down listbox (office2000)
Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » drop down listbox (office2000)
- This topic has 8 replies, 2 voices, and was last updated 21 years, 7 months ago.
AuthorTopicWSalexanderd
AskWoody LoungerOctober 7, 2003 at 9:10 pm #394712Viewing 1 reply threadAuthorReplies-
WSStuartR
AskWoody LoungerOctober 7, 2003 at 9:30 pm #725696Is this in a VBA userform or a Word formfield?
Assuming it is the formfield and you want to create it interactively then…
- Show the forms toolbar
- Click the drop down form field tool
- Right click the new form field and select Properties
- Type the text for the first entry in the Drop down item: box
- Click the Add button
- Now add the next five items the same way
- Click OK
- From the Tools menu select Protect Document, click the Forms radio button and OK
[/list]StuartR
-
WSalexanderd
AskWoody Lounger -
WSStuartR
AskWoody LoungerOctober 8, 2003 at 4:36 pm #726092The easiest thing to do is to populate the drop down list box in the Load or Activate event of the form.
Drag a dropdown list control onto your userform and give it a useful name.
Assuming a userform called frmTest and a control called ctlTest…In the frmText.Load event include code like
ctlTest.AddItem “First”
ctlTest.Additem “SecondStuartR
-
WSalexanderd
AskWoody LoungerOctober 15, 2003 at 9:27 am #729156thank you for all your help. a solution has been sent to me by Doug Robbins-wordMVP which i have coppied for all to see:
Hi Alex,
Using the AddItem method, the following commands in the userform initialize
event will add items Item1, Item2, …. Item10 to a listbox Listbox1 on the
user form:Private Sub UserForm_Initialize()
For i = 1 To 10
ListBox1.AddItem “Item” & i
Next i
End SubThis routine loads a listbox with client details stored in a table in a
separate
document (which makes it easy to maintain with additions, deletions etc.),
that document being saved as Clients.Doc for the following code.On the UserForm, have a list box (ListBox1) and a Command Button
(CommandButton1) and use the following code in the UserForm_Initialize() and
the CommandButton1_Click() routinesPrivate Sub UserForm_Initialize()
Dim sourcedoc As Document, i As Integer, j As Integer, myitem As Range,
m As Long, n As Long
‘ Modify the path in the following line so that it matches where you
saved Suppliers.doc
Application.ScreenUpdating = False
‘ Open the file containing the client details
Set sourcedoc = Documents.Open(FileName:=”e:worddocsClients.doc”)
‘ Get the number or clients = number of rows in the table of client
details less one
i = sourcedoc.Tables(1).Rows.Count – 1
‘ Get the number of columns in the table of client details
j = sourcedoc.Tables(1).Columns.Count
‘ Set the number of columns in the Listbox to match
‘ the number of columns in the table of client details
ListBox1.ColumnCount = j
‘ Define an array to be loaded with the client data
Dim MyArray() As Variant
‘Load client data into MyArray
ReDim MyArray(i, j)
For n = 0 To j – 1
For m = 0 To i – 1
Set myitem = sourcedoc.Tables(1).Cell(m + 2, n + 1).Range
myitem.End = myitem.End – 1
MyArray(m, n) = myitem.Text
Next m
Next n
‘ Load data into ListBox1
ListBox1.List() = MyArray
‘ Close the file containing the client details
sourcedoc.Close SaveChanges:=wdDoNotSaveChanges
End SubPrivate Sub CommandButton1_Click()
Dim i As Integer, Addressee As String
Addressee = “”
For i = 1 To ListBox1.ColumnCount
ListBox1.BoundColumn = i
Addressee = Addressee & ListBox1.Value & vbCr
Next i
ActiveDocument.Bookmarks(“Addressee”).Range.InsertAfter Addressee
UserForm2.Hide
End SubThe Initialize statement will populate the listbox with the data from the
table and then when a client is selected in from the list and the command
button is clicked, the information for that client will be inserted into a
bookmark in the document. You may want to vary the manner in which it is
inserted to suit our exact requirements, but hopefully this will get you
started.To make it easy for you, the code has been written so that it will deal with
any number of clients and any number of details about each client. It
assumes that the first row of the table containing the client details is a
header row. -
WSalexanderd
AskWoody LoungerOctober 15, 2003 at 9:27 am #729157thank you for all your help. a solution has been sent to me by Doug Robbins-wordMVP which i have coppied for all to see:
Hi Alex,
Using the AddItem method, the following commands in the userform initialize
event will add items Item1, Item2, …. Item10 to a listbox Listbox1 on the
user form:Private Sub UserForm_Initialize()
For i = 1 To 10
ListBox1.AddItem “Item” & i
Next i
End SubThis routine loads a listbox with client details stored in a table in a
separate
document (which makes it easy to maintain with additions, deletions etc.),
that document being saved as Clients.Doc for the following code.On the UserForm, have a list box (ListBox1) and a Command Button
(CommandButton1) and use the following code in the UserForm_Initialize() and
the CommandButton1_Click() routinesPrivate Sub UserForm_Initialize()
Dim sourcedoc As Document, i As Integer, j As Integer, myitem As Range,
m As Long, n As Long
‘ Modify the path in the following line so that it matches where you
saved Suppliers.doc
Application.ScreenUpdating = False
‘ Open the file containing the client details
Set sourcedoc = Documents.Open(FileName:=”e:worddocsClients.doc”)
‘ Get the number or clients = number of rows in the table of client
details less one
i = sourcedoc.Tables(1).Rows.Count – 1
‘ Get the number of columns in the table of client details
j = sourcedoc.Tables(1).Columns.Count
‘ Set the number of columns in the Listbox to match
‘ the number of columns in the table of client details
ListBox1.ColumnCount = j
‘ Define an array to be loaded with the client data
Dim MyArray() As Variant
‘Load client data into MyArray
ReDim MyArray(i, j)
For n = 0 To j – 1
For m = 0 To i – 1
Set myitem = sourcedoc.Tables(1).Cell(m + 2, n + 1).Range
myitem.End = myitem.End – 1
MyArray(m, n) = myitem.Text
Next m
Next n
‘ Load data into ListBox1
ListBox1.List() = MyArray
‘ Close the file containing the client details
sourcedoc.Close SaveChanges:=wdDoNotSaveChanges
End SubPrivate Sub CommandButton1_Click()
Dim i As Integer, Addressee As String
Addressee = “”
For i = 1 To ListBox1.ColumnCount
ListBox1.BoundColumn = i
Addressee = Addressee & ListBox1.Value & vbCr
Next i
ActiveDocument.Bookmarks(“Addressee”).Range.InsertAfter Addressee
UserForm2.Hide
End SubThe Initialize statement will populate the listbox with the data from the
table and then when a client is selected in from the list and the command
button is clicked, the information for that client will be inserted into a
bookmark in the document. You may want to vary the manner in which it is
inserted to suit our exact requirements, but hopefully this will get you
started.To make it easy for you, the code has been written so that it will deal with
any number of clients and any number of details about each client. It
assumes that the first row of the table containing the client details is a
header row.
-
-
WSStuartR
AskWoody LoungerOctober 8, 2003 at 4:36 pm #726093The easiest thing to do is to populate the drop down list box in the Load or Activate event of the form.
Drag a dropdown list control onto your userform and give it a useful name.
Assuming a userform called frmTest and a control called ctlTest…In the frmText.Load event include code like
ctlTest.AddItem “First”
ctlTest.Additem “SecondStuartR
-
-
WSalexanderd
AskWoody Lounger
-
-
WSStuartR
AskWoody LoungerOctober 7, 2003 at 9:30 pm #725702Is this in a VBA userform or a Word formfield?
Assuming it is the formfield and you want to create it interactively then…
- Show the forms toolbar
- Click the drop down form field tool
- Right click the new form field and select Properties
- Type the text for the first entry in the Drop down item: box
- Click the Add button
- Now add the next five items the same way
- Click OK
- From the Tools menu select Protect Document, click the Forms radio button and OK
[/list]StuartR
Viewing 1 reply thread -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Rufus is available from the MSFT Store
by
PL1
5 hours, 22 minutes ago -
Microsoft : Ending USB-C® Port Confusion
by
Alex5723
7 hours, 31 minutes ago -
KB5061768 update for Intel vPro processor
by
drmark
3 hours, 45 minutes ago -
Outlook 365 classic has exhausted all shared resources
by
drmark
5 hours, 42 minutes ago -
My Simple Word 2010 Macro Is Not Working
by
mbennett555
3 hours, 17 minutes ago -
Office gets current release
by
Susan Bradley
5 hours, 54 minutes ago -
FBI: Still Using One of These Old Routers? It’s Vulnerable to Hackers
by
Alex5723
1 day, 19 hours ago -
Windows AI Local Only no NPU required!
by
RetiredGeek
1 day, 4 hours ago -
Stop the OneDrive defaults
by
CWBillow
1 day, 20 hours ago -
Windows 11 Insider Preview build 27868 released to Canary
by
joep517
2 days, 6 hours ago -
X Suspends Encrypted DMs
by
Alex5723
2 days, 8 hours ago -
WSJ : My Robot and Me AI generated movie
by
Alex5723
2 days, 9 hours ago -
Botnet hacks 9,000+ ASUS routers to add persistent SSH backdoor
by
Alex5723
2 days, 9 hours ago -
OpenAI model sabotages shutdown code
by
Cybertooth
2 days, 10 hours ago -
Backup and access old e-mails after company e-mail address is terminated
by
M W Leijendekker
1 day, 22 hours ago -
Enabling Secureboot
by
ITguy
2 days, 5 hours ago -
Windows hosting exposes additional bugs
by
Susan Bradley
2 days, 18 hours ago -
No more rounded corners??
by
CWBillow
2 days, 14 hours ago -
Android 15 and IPV6
by
Win7and10
2 days, 3 hours ago -
KB5058405 might fail to install with recovery error 0xc0000098 in ACPI.sys
by
Susan Bradley
3 days, 6 hours ago -
T-Mobile’s T-Life App has a “Screen Recording Tool” Turned on
by
Alex5723
3 days, 9 hours ago -
Windows 11 Insider Preview Build 26100.4202 (24H2) released to Release Preview
by
joep517
3 days, 3 hours ago -
Windows Update orchestration platform to update all software
by
Alex5723
3 days, 16 hours ago -
May preview updates
by
Susan Bradley
3 days, 4 hours ago -
Microsoft releases KB5061977 Windows 11 24H2, Server 2025 emergency out of band
by
Alex5723
2 days, 19 hours ago -
Just got this pop-up page while browsing
by
Alex5723
3 days, 8 hours ago -
KB5058379 / KB 5061768 Failures
by
crown
3 days, 5 hours ago -
Windows 10 23H2 Good to Update to ?
by
jkitc
2 days, 8 hours ago -
At last – installation of 24H2
by
Botswana12
4 days, 8 hours ago -
MS-DEFCON 4: As good as it gets
by
Susan Bradley
6 hours, 10 minutes ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.