list box

R

Ron

I am developing of form in Word.
I can get the dropdown box to work, but how do I get a list box that allows
the selection of multiple entrys, and how do I control the formating of the
output of the list box into my document?
 
G

Greg Maxey

Ron,

You have to set the 'Multiselect" property of the list box.

Assuming that you are using controls directly in a Word document and
not a Userform, then you may be able to adapt this example:

Sub AutoOpen()
Dim oLB As ListBox
Set oLB = ThisDocument.ListBox1
oLB.List = Array("One", "Two", "Three", "Four")
End Sub

Private Sub CommandButton1_Click()
Dim myString As String
Dim pListCnt As Long
Dim i As Long
pListCnt = ThisDocument.ListBox1.ListCount
For i = 1 To pListCnt
If ThisDocument.ListBox1.Selected(i - 1) Then
myString = myString & ThisDocument.ListBox1.List(i - 1) & " "
End If
Next i
ThisDocument.Bookmarks("Test").Range.InsertAfter myString
End Sub
 
D

Doug Robbins - Word MVP

For a list box, you need to be using a UserForm and set the MultiSelect
property of the List Box to 1 - fmMultiSelectMulti

If this is double-dutch to you, See the article "How to create a Userform"
at:

http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
R

Ron

How do you change the "Multiselect" property of the list box? Is this a
function of Visual basic?
 
G

Greg Maxey

Right click it and select properties and scroll down to the multiselect
property.
 
R

Ron

That's the part I don't get. When I right click on it and select properties
I don't get anything with a scoll bar. I get a box titled: "Drop-down Form
Fields Option". It has fields for "Drop-down item", "Items in drop-down
list:" "Run macro on Entry/Exit"; "Bookmark:Dropdown1", and check boxes for
"Drop-down enabled" and "calculate on exit". It doesn't have any options for
"multiselect".

I also tried putting your code in the macro editor, but it doesn't run.
 
D

Doug Robbins - Word MVP

You are using a Dropdown type formfield as is used in a Protected Document.

It is a combobox, not a listbox.

If you want to be able to select multiple items from a list, you must use a
listbox.

While you can put a listbox (from the Controls toolbar -
View>Toolbars>Control), I do NOT recommend it.

Rather, you should probably be using a userform as mentioned in my initial
response to your original post.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
R

Ron Maultsby

Greg

This is strange. There must be another Ron on this thread responding to my
mail. I know how to set the multiselect but maybe the other Ron doesn't.
Anyway, What you sent sounds like what I am trying to do.

Thank you.
 
G

Greg Maxey

Perhaps this other Ron is just having a bit of sport with all of us. I
have often thought that it would be fun to to ask the simpliest
questions and then just not get it no matter hard the the respondents
triedto help. Hmm...wait a minute, the heavies in the VBA group may
feel that I have actually engaged in that sport from time to time.

Gook luck with your form.
 
A

antinyx

Just to clear things up. I am the "Ron" that actually started this string
and I am not trying to have sport with you. I appreciate the explanations,
especially the links to the articles.

Perhaps I am a simpleton, but more likely just uninitiated to programming
Word. Part of the problem is that what I thought was an simple question with
a simple answer like changing a radio button in the wizard has turned out to
be amazingly complex. The challenge for me is that the answers are very
linear, and assume a basic understanding and a vocabulary that I don't have
yet. As a global thinker, I need to see the big picture and work down to the
detail. Unfortunately, most of Microsoft's help entries are small snippets
of detail and it is hard to assemble all the pieces together to get the big
picture without getting lost on a bunny trail. For example, which toolbar you
are referring to? I was using the "Forms", but it doesn't seem to have the
features you refer to. The "Control tool box" looks similar, but slightly
different; what is that all about? And then there are features in "Visual
Basic" that look like they might apply. Is that what you are referring to?
How is the programming in visual basic related to the
documents/templates/userforms?

Then there are the comments about Documents Vs Userforms. I know about
documents, I kind of know about templates (although I didn't understand how
useful they could be until I read the article. - thanks), but I am not sure I
have ever seen a "Userform". (The steps in the article on userforms didn't
work) What do they look like, how do you use them, and how do you create
them? What is the relationship between a Document, a Template, a Userform
and a Database? Are Userforms freestanding objects or do they require a
database to store the answers in? If they require a database, how am I going
to distribute that to other users? Can it be imbeded in the template or in
the userform? And how do I get the answers from that database back into the
document I am trying to create.

Then there are problems with the Templates. When I save them to my USB
drive they don't work. When I change one and then try to save it, it won't
accept the same name. Changing the default location for templates to point to
the USB drive doesn't work, so then, "Where were they originally to change
them back"?

Most of the information in my document stays the same with small changes
every day, so I don't want to start with a new document fresh from the
template everyday. Most of it I want to keep and just edit. So changes I
make in the template don't necessarily show up in the document. But
occasionally whole sections start fresh, so I have been editing my template
and then cutting and pasting sections into the document so that it evolves
over time. It works for me, but a little complicated for other users.

Another problem is that not all parts of the document are used everyday, so
how can I make it so only the parts being used that day are printed?

So, to make a long story short, I still haven't figured out how to implement
the answers to my original question, but I am learning a lot. Thanks for
trying.
 
G

Greg Maxey

Ron,

Sorry about the foopah. I never meant to imply that you were a
simpleton. In fact I have been in practically the very same situation
that you are *overwhelmed by Word* not that long ago. There is still
much I don't understand and spend a fair amount of time on the
bunnytrail ;-)
From the decription of your needs, it sounds like you need a template
(stored in your template directory that contains the *boilerplate* text
of your very similiar daily document. Then have a Userform that
*appears* each time you create a new document using that template. I
am still on the bunnytrail when it comes to giving a technical
explanation of what a Userform is. It is created using VBA. I am off
to work just now so can't go into great detail. Have a long at these
links and you will at least see what a userform looks like:

http://gregmaxey.mvps.org/Validate_UserForm_TextEntry.htm
http://gregmaxey.mvps.org/Custom_MsgBox.htm
 
A

antinyx

Greg,

Thank you this looks helpful. (One more piece to the puzzle). I am off to a
cousisn's wedding myself, so I will look at it more next week.
 

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