To the SMART WOMAN!!!!I have the following code in a UserForm which has two comboxes, and the first comboxbox is my list of categories...and the second combobox shows the contact names of the contacts that are a part of the category I click on in the first combobox....but the name of the contact is not a link to the contact....so is there a quick fix to this so that the line which is:
Me.ddlContacts.addItem ctc.FullName is changed so it is not just the FullName of the contact, but the link to the contact....
so here is the code and I appreciate a quick response and it solves everything for me.....thanks much:
Private Sub ddlCategories_Change()
Dim objOutlook As outlook.Application
Dim objNS As outlook.NameSpace
Dim objFolder As outlook.MAPIFolder
Dim objFolder2 As outlook.MAPIFolder
Dim objFolder3 As outlook.MAPIFolder
Dim objFolder4 As outlook.MAPIFolder
Dim objFolder5 As outlook.MAPIFolder
Dim objFolder6 As outlook.MAPIFolder
Dim objFolder7 As outlook.MAPIFolder
Dim objFolder8 As outlook.MAPIFolder
Dim ctc As ContactItem
Dim Category As String
Set objOutlook = CreateObject("Outlook.Application")
Set objFolder = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts)
Set objFolder2 = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders("Test")
Set objFolder3 = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders("Family")
Set objFolder4 = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders("Friends")
Set objFolder5 = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders("Test2")
Set objFolder6 = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders("Test3")
Set objFolder7 = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders("Test").Folders("SubTest")
Set objFolder8 = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders("Test").Folders("SubTest2")
Category = Me.ddlCategories.Text
Me.ddlContacts.Clear
For Each ctc In objFolder.items
If ctc.Categories = Category Then
Me.ddlContacts.addItem ctc.FullName
End If
Next
For Each subFolder In objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders
addItem subFolder, Category
Next
For Each subFolder In objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders("Test").Folders
addItem subFolder, Category
Next
End Sub
Private Sub addItem(subFolder, categoriesName As String)
For Each ctc In subFolder.items
If ctc.Categories = categoriesName Then
Me.ddlContacts.addItem ctc.FullName
End If
Next
End Sub
Private Sub UserForm_Initialize()
Dim Category
For Each Category In Application.Session.Categories
Me.ddlCategories.addItem Category
Next
End Sub
Me.ddlContacts.addItem ctc.FullName is changed so it is not just the FullName of the contact, but the link to the contact....
so here is the code and I appreciate a quick response and it solves everything for me.....thanks much:
Private Sub ddlCategories_Change()
Dim objOutlook As outlook.Application
Dim objNS As outlook.NameSpace
Dim objFolder As outlook.MAPIFolder
Dim objFolder2 As outlook.MAPIFolder
Dim objFolder3 As outlook.MAPIFolder
Dim objFolder4 As outlook.MAPIFolder
Dim objFolder5 As outlook.MAPIFolder
Dim objFolder6 As outlook.MAPIFolder
Dim objFolder7 As outlook.MAPIFolder
Dim objFolder8 As outlook.MAPIFolder
Dim ctc As ContactItem
Dim Category As String
Set objOutlook = CreateObject("Outlook.Application")
Set objFolder = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts)
Set objFolder2 = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders("Test")
Set objFolder3 = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders("Family")
Set objFolder4 = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders("Friends")
Set objFolder5 = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders("Test2")
Set objFolder6 = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders("Test3")
Set objFolder7 = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders("Test").Folders("SubTest")
Set objFolder8 = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders("Test").Folders("SubTest2")
Category = Me.ddlCategories.Text
Me.ddlContacts.Clear
For Each ctc In objFolder.items
If ctc.Categories = Category Then
Me.ddlContacts.addItem ctc.FullName
End If
Next
For Each subFolder In objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders
addItem subFolder, Category
Next
For Each subFolder In objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders("Test").Folders
addItem subFolder, Category
Next
End Sub
Private Sub addItem(subFolder, categoriesName As String)
For Each ctc In subFolder.items
If ctc.Categories = categoriesName Then
Me.ddlContacts.addItem ctc.FullName
End If
Next
End Sub
Private Sub UserForm_Initialize()
Dim Category
For Each Category In Application.Session.Categories
Me.ddlCategories.addItem Category
Next
End Sub