0
我有下面的代碼填充我的Outlook聯繫人的名稱列表框。我希望在單擊某個項目時將地址輸入到我的表單上的文本框中。只要說,我不知道該怎麼做......任何幫助?VBA填充列表框上的文本框從Outlook聯繫人點擊
Private Sub getContacts()
Dim x 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)
For Each oContact In oContacts.Items
Me.ListBox1.AddItem oContact.LastNameAndFirstName
x = x + 1
Next
Set oContact = Nothing
Set oContacts = Nothing
Set oOutlookNameSpace = Nothing
Set oOutlookApp = Nothing
End Sub