View Single Post
  #2  
Old November 11th 08, 08:00 PM posted to microsoft.public.outlook.program_vba
salad
external usenet poster
 
Posts: 27
Default Link To Outlook Address Book Slow

DEI wrote:
Greetings,

I would like the display names in an Outlook global address list to be
available in a combo box on a form in MS Access. I have created a linked
table to the
Outlook Global Address list in the database, and am referencing the table in
the form, but it operates at an unacceptably slow speed. I can select the
names, but the autocomplete takes minutes find the name.

Is there some way of retrieving these values from the Outlook object model
programmatically so that it runs much faster? I would ultimately like for
the user to be able to select a name from the list.

Incidentally, I can retrive AddressEntries properties via the Outlook Object
model, but I get the warning message each tim the code tried to retirve a
proprty (i.e. name, etc.)

Thanks in advance.

DEI

When listboxes or combos get too complicated I suggest using a UDF (user
defined function) rowtype instead of ValueList or Table/Query. Here's
some code I provided to someone in the Access newsgroup to demonstrate
how to make one. It scans all of the queries in the database and
presents them in a listbox. Once you make a UDF rowtype you have the
template for any others you need in the future.

You can find an explanation of a combo/listbox UDF in help. In A97, the
topic is "RowSourceType Property (User-Defined Function) — Code Argument
Values"

I dropped this code in the form's code module.

Option Explicit
Option Compare Database
Private Type QueryList
'change the type name/column names to whatever you like.
QueryName As Variant
'QueryDate as Date
'add any other columns associated with this type
End Type
Private Function FillQueryList(fld As Control, ID As Variant, row As
Variant, col As Variant, Code As Variant) As Variant
On Error Resume Next

Static strRows() As QueryList
Static Entries As Integer
Dim qdf As QueryDef
Dim ReturnVal As Variant

ReturnVal = Null

Select Case Code
Case acLBInitialize ' Initialize.

Entries = 0
ReDim Preserve strRows(Entries)

'creates header/column row. Useful if colheads is True
strRows(Entries).QueryName = "Query Name"

For Each qdf In CurrentDb.QueryDefs
If Left(qdf.Name, 1) "~" Then
Entries = Entries + 1
ReDim Preserve strRows(Entries)
strRows(Entries).QueryName = qdf.Name
End If
Next qdf

ReturnVal = True
Case acLBOpen ' Open.
ReturnVal = Timer ' Generate unique ID for control.
Case acLBGetRowCount ' Get number of rows.
ReturnVal = Entries + 1
Case acLBGetColumnCount ' Get number of columns.
ReturnVal = 1
Case acLBGetColumnWidth ' Column width.
ReturnVal = -1 ' -1 forces use of default width.
Case acLBGetValue ' Get data.
Select Case col
Case 0
'this example has a single column.
ReturnVal = strRows(row).QueryName
'Case 1...Case column cnt
' returnVal = strRows(row).theTypeRowName
End Select
Case acLBEnd ' End.
Erase strRows
End Select
FillQueryList = ReturnVal
End Function

Now create a listbox, 1 column to display query name.

In the Listbox's RowSourceType row (under Data tab) enter
FillQueryList
without a preceding "=" and then blank out the RowSource row.

Save the form and run.


In your case, you need to modify the code under the following statements.
Case acLBInitialize ' Initialize.
'get the address list in order.
Case acLBGetColumnCount ' Get number of columns.
'change the column count if necessary
Case acLBGetValue ' Get data.
'fill in the column values.
Ads