Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>Private Sub getOutlookContacts() Dim i As Integer Dim oOutlookApp As Outlook.Application Dim oOutlookNameSpace As Outlook.NameSpace Dim oContacts As Outlook.MAPIFolder Dim oContact As Outlook.ContactItem Dim vaContacts As Variant On Error Resume Next Set oOutlookApp = New Outlook.Application Set oOutlookNameSpace = oOutlookApp.GetNamespace("MAPI") 'Get the contactfolder Set oContacts = oOutlookNameSpace.GetDefaultFolder(olFolderContacts) Set oContact = oContacts.Items ReDim vaContacts(0 To oContacts.Items.Count - 1, 0 To 1) 'oContacts.Sort "[FullName]", False, olAscending For Each oContact In oContacts.Items vaContacts(i, 0) = oContact.FullName vaContacts(i, 1) = oContact.BusinessAddress i = i + 1 Next oContact SortArray vaContacts Me.ListBox1.Clear Me.ListBox1.List = vaContacts Set oContact = Nothing Set oContacts = Nothing Set oOutlookNameSpace = Nothing Set oOutlookApp = Nothing End Sub Private Sub SortArray(ByRef vaArray As Variant) Dim i As Long Dim j As Long Dim sTemp As String Dim sTemp2 As String 'Bubble sort the array on the first value For i = LBound(vaArray, 1) To UBound(vaArray, 1) - 1 For j = i + 1 To UBound(vaArray, 1) If vaArray(i, 0) &gt; vaArray(j, 0) Then 'Swap the first value sTemp = vaArray(i, 0) vaArray(i, 0) = vaArray(j, 0) vaArray(j, 0) = sTemp 'Swap the second value sTemp2 = vaArray(i, 1) vaArray(i, 1) = vaArray(j, 1) vaArray(j, 1) = sTemp2 End If Next j Next i End Sub </code></pre> <p>See also <a href="http://www.dailydoseofexcel.com/archives/2004/05/24/sorting-a-multicolumn-listbox/" rel="nofollow">http://www.dailydoseofexcel.com/archives/2004/05/24/sorting-a-multicolumn-listbox/</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload