2 열 목록 상자에 내 Outlook 연락처 폴더의 내용을 채우고 해당 정보를 클릭하여 텍스트 상자로 보낼 수 있습니다 ... 아아, 목록 상자를 정렬하려면 어떻게해야합니까?VBA Outlook 연락처의 목록 상자 정렬
oContacts.Items.Sort "[FullName]", False
Set oContact = oContacts.Items.GetFirst
Do
' Add oContact details to the listbox
Set oContact = oContacts.Items.GetNext
Loop Until oContact Is Nothing
이 가장 가능성 언급, 빠를하지 않는 것입니다 :
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
On Error Resume Next
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
End If
Set oOutlookNameSpace = oOutlookApp.GetNamespace("MAPI")
'Get the contactfolder
Set oContacts = oOutlookNameSpace.GetDefaultFolder(olFolderContacts)
Set oContact = oContacts.Items
'oContacts.Sort "[FullName]", False, olAscending
For Each oContact In oContacts.Items
Me.ListBox1.AddItem oContact.FullName
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = oContact.BusinessAddress
i = i + 1
Next
Set oContact = Nothing
Set oContacts = Nothing
Set oOutlookNameSpace = Nothing
Set oOutlookApp = Nothing
End Sub
예상되는 대답을 얻었 으면 받아 들여야합니다. – Pieniadz