Category List

Status
Not open for further replies.

LMS

Senior Member
Outlook version
Email Account
Exchange Server
Someone told me another easy way is to assign contacts to a category...and then there is the userform22 that has the code re a combobox that opens up the list of the categories...but when I click on a category there is the error: End With without With...so it does not open up the category and the list of the contacts in the category....here is the code re the Userform22....and I have it as a link to the OutlookSession which is how I run it. Any changes that fixes it...and shows the list of the contacts in the category I click on...also, need the category list to be on a alphabetic list....A down to Z etc...

Private Sub ComboBox26_Change()
For Each item In objoutlook.contactItems
If item.Category = Category Then
Me.ComboBox1.AddItem item.FullName
End If
Next
End With


End Sub

Private Sub UserForm_Initialize()
Dim Category
For Each Category In Application.Session.Categories
Me.ComboBox26.AddItem Category
Next


End Sub
 
So is there a code in the userform that has two comboboxes and the droplist of the first one is the list of categories and the second after i click on a specific category is the list if names of the contacts in the category and they are links to the contact?

Waiting on the Smart Woman!!
 
Try this:




Private Sub ComboBox26_Change()



For Each item In objoutlook.contactItems
If item.Category = Category Then
Me.ComboBox1.AddItem item.FullName
End If
Next




end sub




the with would be used something like this - which you aren't doing (and don't need to do)


with item
.category = "whatever"


end with
 
The other combobox is ComboBox27 so I changed that...I ran it...is shows the the two comboboxes....the first one shows all categories but not in the line of the A to a Z...its a different form of list not in the alphabettical way....and then when I identify a category that I know has 5 contacts to it, I get the error:

"Runtime Error, 424, Object Required....and the following is yellowed: "For Each item In objOutlook.contactItems"

Great to hear back what to fix and when the list of contacts show up re the category, need to be able to click on the contact to open the contact.

Thanks so much to the "Smart Woman"!!!
 
I don't know what is the best...but here is the code some else had given me...it only shows the contacts of the category from the top Contact folder...not from any other folders that were created by right clicking on Contact and create a new folder....so there are subfolders of the Contact folder and it is not showing anything from those subfolders.....and whatever it shows, is not a link to the contact itself...so here is that other code and would love to hear back!!! PS, I changes the name of the comboboxes re what this code shows.

Private Sub ddlCategories_Change()
Dim objOutlook As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim ctc As ContactItem
Dim Category As String

Set objOutlook = CreateObject("Outlook.Application")
Set objFolder = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts)
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


End Sub

Private Sub UserForm_Initialize()
Dim Category
For Each Category In Application.Session.Categories
Me.ddlCategories.AddItem Category
Next

End Sub
 
This line:

Set objFolder = objOutlook.Session.GetDefaultFolder(OlDefaultFolde rs.olFolderContacts)

tells the code to look in the contacts folder. I don't know the best way to make it use all folders - other than not use separate folders.
 
Thank you. If I don't need to search all folders, just specific subfolders that are each a subfolder of Contacts, how to list those in the code so it searches just the specific subfolders i want to use ?
 
subfolders are called using this format:

Set objFolder = objOutlook.Session.GetDefaultFolder(olFolderContacts).Folders("subfoldername")
 
Got it....and how can I add more than one subfolder to the code so it looks into more than one subfolder..and I have the name for the subfolders....
 
i don't know how to do it and be efficient, or even if you can.
 
Just in case...is there a chance that at the end of the line there is something like the word and or & that simply adds another folder to the list? I tried it but don't know how to add an "and" to something...
 
AFAIK, you can't use AND when setting the folder object - it can't represent two folders.
 
So nothing else to do??????? Any possible way????
 
Next Way to Think About It: In the past you gave me a Module Code macro that would be a string of macros that were created in another Module...and then in the Userform Combobox, we had a list of those macros...so is there away to create a separate Module Code as a Macro that has the string list of each Userform that has the search of one Folder.....and then create a Userform that shows the string list of Userforms from the Module Code? That way I have a list of the Folders that are searched that have some contacts assigned to a Category........??
 
That was different - the only way i can think to do this is to read all the names in one folder to create an array then move to the second folder and add those names to the array. When you do anything with a name, you need to search the folders to find the contact. I don't have any code samples that will do it though. Plus it can be slow, especially if you are using more than 2 folders or have a lot of contacts. There may be other ways to do it, but if so, its out of my league.
 
Have to tell something else just in case there is way to do it....I added to the code the concept of olFolder = OlFolder2 and created what olFolder2 refers to as you will see below, and that has me go to the subfolder of olFolder2.....and I created olFolder3 which goes to another subfolder....so is there a way to code ofFolder equals both olFolder2 and oldFolder3?

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 ctc As ContactItem
Dim Category As String

Set objOutlook = CreateObject("Outlook.Application")
Set objFolder = objFolder2
Set objFolder2 = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders("Test")
Set objFolder3 = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts).Folders("Family")
Category = Me.ddlCategories.Text

Me.ddlContacts.Clear

For Each ctc In objFolder2.Items
If ctc.Categories = Category 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
 
Right now, no update. :)
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
farrissf Category list to pick from Outlook VBA and Custom Forms 4
J Outlook Rules not show Master Category List Using Outlook.com accounts in Outlook 4
M Searching for categories not in the master category list Using Outlook 3
R Restore Master Category List Outlook 2013 Using Outlook 7
K Master Category List / Contacts Public Folder Advice Using Outlook 4
L Anyway to Display entire category list in Outlook 2007 automatically? Using Outlook 1
B Outlook 2019 Automatically move email after assigning category Using Outlook 4
F Add a category before "Send an Email When You Add an Appointment to Your Calendar" Outlook VBA and Custom Forms 0
V Macro to mark email with a Category Outlook VBA and Custom Forms 4
P Emails assigned with a certain category (within a shared inbox) to be copied to a specific folder. Outlook VBA and Custom Forms 2
R Clear one category when another is chosen Outlook VBA and Custom Forms 1
A VBA Script - Print Date between first email in Category X and last email in Category Y Outlook VBA and Custom Forms 3
R Auto Assign Category colours to Incoming Emails based on whom the email is addressed Outlook VBA and Custom Forms 3
A Unflag Inbox and Flag Inbox with Orange Category After Item is send Outlook VBA and Custom Forms 3
bhamberg Contacts in a category Outlook VBA and Custom Forms 11
K Custom Category Colors Using Outlook 2
4 Macro to set the category of Deleted Item? Outlook VBA and Custom Forms 2
K Update Appointment category when changed in Excel Using Outlook 3
soadfan assign category (VBA) Using Outlook 7
J Automatic color category according to variable domains Outlook VBA and Custom Forms 4
Diane Poremsky Category Color doesn't Display in Inbox Using Outlook 0
Wolfkc Unwanted Category "Starred in Android" Using Outlook 6
M receive mail when appointment category changes and create task from appointment Outlook VBA and Custom Forms 0
N VBA Outlook reference to Excel and assigning category Outlook VBA and Custom Forms 13
A recover contact category assignments Using Outlook 4
A Grouping emails using "From" causes a None Category Using Outlook 5
William getting custom form to load category colors Outlook VBA and Custom Forms 4
Diane Poremsky Categorize Messages using Contact Category Using Outlook 0
T Macro to find contacts by category and copy them to another folder Outlook VBA and Custom Forms 15
bifjamod Saving sent email to specific folder based on category with wildcard Outlook VBA and Custom Forms 1
K Outlook 2010 - Set the category based on category of other emails in same conversatio Using Outlook 20
A How are you handling Outlook.com category issue and syncing Using Outlook.com accounts in Outlook 2
T default category Outlook VBA and Custom Forms 2
R click to toggle quick click category reasigns to where ? Using Outlook 2
L Change Category in a Task via macro Using Outlook 8
K Help! I selected every contact and mistakenly made them all the same category Using Outlook 1
R Filter Views by Category Using Outlook 2
S categories are being cut off after selecting from category pop up form Using Outlook 3
D Search on Category in Outlook 2013 Using Outlook 1
R Any idea why my category colours aren't showing in my calendar? Using Outlook 0
F Export Outlook contacts by One Category Using Outlook 1
M Cannot change category in inbox; Can change it in popup Using Outlook 0
D Macro to export mail data based on assigned category Using Outlook 3
C Custom form with custom colour category visible to all users in public folders Using Outlook 1
J Contacts: Assigning followup date by category Using Outlook 2
C Apply Category Color for Appointment Background Color Using Outlook 2
J Calendar Search by Category not showing expected results Using Outlook 7
S Printing Category Key on Calendar Using Outlook 1
A Can Rule Check Category Contact is assigned? Using Outlook 1
J View All Category Items Using Outlook 1

Similar threads

Back
Top