Share this Page URL
Help

UserForms > UserForms - Pg. 445

Dim lst As MSForms.ListBox Private Sub UserForm_Initialize( ) 'Fill listbox with contact names from Outlook 'Created by Helen Feddema 5-20-2000 'Last modified 5-21-2000 On Error GoTo ErrorHandler Dim Dim Dim Dim Dim Dim Dim Dim appOutlook As New Outlook.Application nms As Outlook.NameSpace fld As Outlook.MAPIFolder itms As Outlook.Items strContactArray( ) As String lngContactCount As Long itm As Object lngRow As Long Me![txtLetterText].Value = "Type letter text here" Set nms = appOutlook.GetNamespace("MAPI") Set fld = nms.GetDefaultFolder(olFolderContacts) Set itms = fld.Items lngContactCount = itms.Count itms.Sort "[LastName]", False Set lst = lstContacts lngContactCount = itms.Count If lngContactCount = 0 Then MsgBox "No contacts found in Contacts folder"