View Single Post
Old November 28th 13, 05:30 AM
danie11e.m danie11e.m is offline
Junior Member
First recorded activity at Outlookbanter: Nov 2013
Posts: 1
Default Can't select option in combobox

This is the first time I have tried writing code or script of any sort so I need all the help I can get!

I have a 2 column combobox which I have gotten to display all of my outlook contact's full name and organisation id number successfully.

However I cannot select a contact from the combobox and autocomplete doesn't work.

Is this is because I need to assign a value? I have made a field in the properties tab of the combobox called Specifiers2 if that helps with setting the value.

All of the scripts I have found don't work and I've been Googling for days now.

Here is my code which is located in Outlook's Script Editor:

Sub Item_Open()

Dim FullArray()

' Sets the name of page on the form (Activity Sheet)
Set FormPage = Item.GetInspector.ModifiedFormPages("Activity Sheet")

' Sets Control to a list box called ComboBox1.
Set Control = FormPage.Controls("ComboBox1")

' Get the default Contacts folder
Set ConFolder1 = Application.Session.GetDefaultFolder(10)
Set ConFolder2 = ConFolder1.Folders("Nswlist")

' Get the items in the folder
Set ConItems = ConFolder2.Items

' Get the number of total items in the Contacts folder
NumItems = ConItems.Count

' Resize array to handle total number of item in the folder
ReDim FullArray(NumItems-1,2)

' Loop through all of the items in the Contacts folder,
' filling the array with sample data and keeping track
' of the number of contacts found.
NumContacts = 0
For I = 1 to NumItems
Set itm = ConItems(I)
If Left(itm.MessageClass, 11) = "IPM.Contact" Then
NumContacts = NumContacts + 1
FullArray(NumContacts-1,1) = itm.CompanyName
FullArray(NumContacts-1,2) = itm.OrganizationalIDNumber
End If

' Set the control to handle 2 data columns
Control.ColumnCount = 3

If NumItems = NumContacts Then
' They are all contacts, so use the FullArray
Control.List() = FullArray
' There's some distribution lists, so use the smaller
' ConArray to eliminate extra blank values in the list box
Dim ConArray()
ReDim ConArray(NumContacts-1,2)
For I = 0 to NumContacts - 1
ConArray(I,1) = FullArray(I,1)
ConArray(I,2) = FullArray(I,2)
Control.List() = ConArray
End If

End Sub