Testing for Selection

D

dsc

I have a three-column ListBox populated from an array.

I want to test to see if one of the rows is selected, in the same way you
can test if something is selected in a document:

If SelectionType = wdSelectionNormal Then

Can this be done?

Thanks for any assistance.
 
J

Jezebel

It's not remotely related to the selection within the document.

The ListBox's ListIndex property points to the selected row (counting from
0); -1 means nothing is selected.

With ListBox1
If .ListIndex >= 0 then
Msgbox "Selected item = " & .List(.ListIndex)
End if
End with

A ListBox also has a Selected() array property, corresponding to the items
in the list. If MultiSelect is TRUE, more than one row may be selected.

With ListBox1
For i = 0 to .ListCount - 1
If .Selected(i) then
Msgbox "Selected item = " & .List(i)
End if
Next
End with
 
D

dsc

Works great. Thanks a lot.

Jezebel said:
It's not remotely related to the selection within the document.

The ListBox's ListIndex property points to the selected row (counting from
0); -1 means nothing is selected.

With ListBox1
If .ListIndex >= 0 then
Msgbox "Selected item = " & .List(.ListIndex)
End if
End with

A ListBox also has a Selected() array property, corresponding to the items
in the list. If MultiSelect is TRUE, more than one row may be selected.

With ListBox1
For i = 0 to .ListCount - 1
If .Selected(i) then
Msgbox "Selected item = " & .List(i)
End if
Next
End with
 

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