How to get selected values from an Outlook Multiselect listbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using an Outlook contact form with a multiselect listbox. I'm trying to find a way in visual basic to get the values of items in the listbox that have been selected. I don't know how to reference the values in the multiselect listbox. Can anyone help me with this
Thanks
Warren
 
You need to check the value of the Selected property for each item in the
list.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Warren said:
I'm using an Outlook contact form with a multiselect listbox. I'm trying
to find a way in visual basic to get the values of items in the listbox that
have been selected. I don't know how to reference the values in the
multiselect listbox. Can anyone help me with this?
 
Hi Sue, I'm still not sure how

I've defined the field in VB as follows
Dim Services As ListItems 'is the correct

My Outlook multiselect listbox field is called "Services Provided" consisting of 6 possible values
I've tried to reference "Services Provided" in VB using the following code

Services(1) = objContact.UserProperties("Services Provided").Valu

but I get a "type mismatch" error


----- Sue Mosher [MVP-Outlook] wrote: ----

You need to check the value of the Selected property for each item in th
list

--
Sue Mosher, Outlook MV
Author o
Microsoft Outlook Programming - Jumpstart fo
Administrators, Power Users, and Developer
http://www.outlookcode.com/jumpstart.asp


Warren said:
I'm using an Outlook contact form with a multiselect listbox. I'm tryin
to find a way in visual basic to get the values of items in the listbox tha
have been selected. I don't know how to reference the values in th
multiselect listbox. Can anyone help me with this
 
No, as I said, you need to use the Selected property. Basic usage, from the
Help topic for that property:

For i = 0 To 9
If ListBox1.Selected(i) = True Then
ListBox2.AddItem ListBox1.List(i)
End If
Next i

See http://www.outlookcode.com/d/propsyntax.htm#unbound for information on
the syntax for accessing a control on an Outlook form. You will need to
specify the page as well as the control name. Once you have the control
object, you can use:

For i = 0 to (MyListBox.ListCount -1)
If MyListBox1.Selected(i) Then
MsgBox MyListBox.List(i) & " is selected"
End If
Next

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Warren said:
Hi Sue, I'm still not sure how.

I've defined the field in VB as follows:
Dim Services As ListItems 'is the correct ?

My Outlook multiselect listbox field is called "Services Provided"
consisting of 6 possible values.
I've tried to reference "Services Provided" in VB using the following code:

Services(1) = objContact.UserProperties("Services Provided").Value

but I get a "type mismatch" error.



----- Sue Mosher [MVP-Outlook] wrote: -----

You need to check the value of the Selected property for each item in the


Warren said:
I'm using an Outlook contact form with a multiselect listbox. I'm
trying
to find a way in visual basic to get the values of items in the listbox that
have been selected. I don't know how to reference the values in the
multiselect listbox. Can anyone help me with this?
Thanks.
Warren
 
Back
Top