Setting category when creating appointment in Outlook 2007 from Ac

J

JoD

I would like to be able to, when the user chooses (from a combo box on the
form) the calendar to which the appointment will be added, display the
current choices of categories for the calendar, have the user select the
appropriate category, and then click "Add to Outlook" to add the appointment,
complete with the desired category color.

The problem is that the Categories property is associated with the
AppointmentItem object and to retrieve it, I would have to add the item. I
don't want to add the item until all information has been gathered. Then, if
I understand correctly, in order to set the particular category that is
chosen, that I will need to reference the "category" property of a
FormsDescription object that is asssociated with AppointmentItem object.

I have the code in place to add the appointment item and have successfully
tested it with the ability to choose the calendar.
 
G

Graham Mandeno

Hi JoD

I think you are confusing three things here:

1. The Categories collection, which is a property of the NameSpace, and
which contains the master list of all registered categories.

2. The Categories property of an OutlookItem, which is a comma-separated
string listing the categories applied to that item.

3. The Category property, which applies to the FormDescription object and
has nothing to do with what you want.

You can use the Categories collection to populate a RowSource of a combo or
listbox (I suggest a multi-select listbox, because you can apply multiple
categories to an appointment). Something like this:

With olkNameSpace.Categories
For i = 1 to .Count
lstCategories.AddItem .Item(i)
Next i
End With

You may wish to read them into an array and sort them alphabetically.

Then, you can construct a comma-separated list of the selected categories in
a string variable and assign it to the Categories property of the
AppointmentItem after you have created the item and before you save it:

Set olkApt = olkFolder.Items.Add(olAppointmentItem)
with olkApt
.Start = ...
.End = ...
...
.Categories = strCategoryList
.Save
End With
 
J

JoD

Thank you. Yes, I was pretty sure I was confusing the issue. This looks like
it will do exactly what I want.

Jo

Graham Mandeno said:
Hi JoD

I think you are confusing three things here:

1. The Categories collection, which is a property of the NameSpace, and
which contains the master list of all registered categories.

2. The Categories property of an OutlookItem, which is a comma-separated
string listing the categories applied to that item.

3. The Category property, which applies to the FormDescription object and
has nothing to do with what you want.

You can use the Categories collection to populate a RowSource of a combo or
listbox (I suggest a multi-select listbox, because you can apply multiple
categories to an appointment). Something like this:

With olkNameSpace.Categories
For i = 1 to .Count
lstCategories.AddItem .Item(i)
Next i
End With

You may wish to read them into an array and sort them alphabetically.

Then, you can construct a comma-separated list of the selected categories in
a string variable and assign it to the Categories property of the
AppointmentItem after you have created the item and before you save it:

Set olkApt = olkFolder.Items.Add(olAppointmentItem)
with olkApt
.Start = ...
.End = ...
...
.Categories = strCategoryList
.Save
End With

--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand


JoD said:
I would like to be able to, when the user chooses (from a combo box on the
form) the calendar to which the appointment will be added, display the
current choices of categories for the calendar, have the user select the
appropriate category, and then click "Add to Outlook" to add the
appointment,
complete with the desired category color.

The problem is that the Categories property is associated with the
AppointmentItem object and to retrieve it, I would have to add the item. I
don't want to add the item until all information has been gathered. Then,
if
I understand correctly, in order to set the particular category that is
chosen, that I will need to reference the "category" property of a
FormsDescription object that is asssociated with AppointmentItem object.

I have the code in place to add the appointment item and have successfully
tested it with the ability to choose the calendar.
 
J

JoD

With your help, I was able to successfully fill the combo box with the
categories. Unfortunately, the scope of the Categories collection of the
NameSpace object is too broad, and doesn't include the custom categories that
I have set for each calendar. Apparently, neither the MAPIFolder object or
Items object have a Categories collection.

Is there anyway to get the custom categories without having to add an
appointment item?

TIA

Graham Mandeno said:
Hi JoD

I think you are confusing three things here:

1. The Categories collection, which is a property of the NameSpace, and
which contains the master list of all registered categories.

2. The Categories property of an OutlookItem, which is a comma-separated
string listing the categories applied to that item.

3. The Category property, which applies to the FormDescription object and
has nothing to do with what you want.

You can use the Categories collection to populate a RowSource of a combo or
listbox (I suggest a multi-select listbox, because you can apply multiple
categories to an appointment). Something like this:

With olkNameSpace.Categories
For i = 1 to .Count
lstCategories.AddItem .Item(i)
Next i
End With

You may wish to read them into an array and sort them alphabetically.

Then, you can construct a comma-separated list of the selected categories in
a string variable and assign it to the Categories property of the
AppointmentItem after you have created the item and before you save it:

Set olkApt = olkFolder.Items.Add(olAppointmentItem)
with olkApt
.Start = ...
.End = ...
...
.Categories = strCategoryList
.Save
End With

--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand


JoD said:
I would like to be able to, when the user chooses (from a combo box on the
form) the calendar to which the appointment will be added, display the
current choices of categories for the calendar, have the user select the
appropriate category, and then click "Add to Outlook" to add the
appointment,
complete with the desired category color.

The problem is that the Categories property is associated with the
AppointmentItem object and to retrieve it, I would have to add the item. I
don't want to add the item until all information has been gathered. Then,
if
I understand correctly, in order to set the particular category that is
chosen, that I will need to reference the "category" property of a
FormsDescription object that is asssociated with AppointmentItem object.

I have the code in place to add the appointment item and have successfully
tested it with the ability to choose the calendar.
 
G

Graham Mandeno

Hi Jo

I didn't even know that you can create custom categories that apply to a
single folder and not to the whole namespace. I have many custom
categories, but they are are all available by enumerating the
NameSpace.Categories collection.

Sorry I can't be of further help here. Perhaps you could try posting your
question in an Outlook newsgroup?

--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

JoD said:
With your help, I was able to successfully fill the combo box with the
categories. Unfortunately, the scope of the Categories collection of the
NameSpace object is too broad, and doesn't include the custom categories
that
I have set for each calendar. Apparently, neither the MAPIFolder object
or
Items object have a Categories collection.

Is there anyway to get the custom categories without having to add an
appointment item?

TIA

Graham Mandeno said:
Hi JoD

I think you are confusing three things here:

1. The Categories collection, which is a property of the NameSpace, and
which contains the master list of all registered categories.

2. The Categories property of an OutlookItem, which is a comma-separated
string listing the categories applied to that item.

3. The Category property, which applies to the FormDescription object and
has nothing to do with what you want.

You can use the Categories collection to populate a RowSource of a combo
or
listbox (I suggest a multi-select listbox, because you can apply multiple
categories to an appointment). Something like this:

With olkNameSpace.Categories
For i = 1 to .Count
lstCategories.AddItem .Item(i)
Next i
End With

You may wish to read them into an array and sort them alphabetically.

Then, you can construct a comma-separated list of the selected categories
in
a string variable and assign it to the Categories property of the
AppointmentItem after you have created the item and before you save it:

Set olkApt = olkFolder.Items.Add(olAppointmentItem)
with olkApt
.Start = ...
.End = ...
...
.Categories = strCategoryList
.Save
End With

--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand


JoD said:
I would like to be able to, when the user chooses (from a combo box on
the
form) the calendar to which the appointment will be added, display the
current choices of categories for the calendar, have the user select
the
appropriate category, and then click "Add to Outlook" to add the
appointment,
complete with the desired category color.

The problem is that the Categories property is associated with the
AppointmentItem object and to retrieve it, I would have to add the
item. I
don't want to add the item until all information has been gathered.
Then,
if
I understand correctly, in order to set the particular category that is
chosen, that I will need to reference the "category" property of a
FormsDescription object that is asssociated with AppointmentItem
object.

I have the code in place to add the appointment item and have
successfully
tested it with the ability to choose the calendar.
 
J

JoD

Hi Graham,

Thanks for your prompt response. I didn't realize until now that you could
change categories by going to Edit/Categorize. That appears to be the
NameSpace collection and will affect items in any folder - mail, calendar,
tasks etc.

The collection that I need to expose is created by entering an item in a
specific folder. The categories can be set that way also, but apparently not
then added to the master (NameSpace) collection. Those categories however are
available to any new item added to the folder.

I will take your helpful advice and post my question in the Outlook
discussion group.


Graham Mandeno said:
Hi Jo

I didn't even know that you can create custom categories that apply to a
single folder and not to the whole namespace. I have many custom
categories, but they are are all available by enumerating the
NameSpace.Categories collection.

Sorry I can't be of further help here. Perhaps you could try posting your
question in an Outlook newsgroup?

--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

JoD said:
With your help, I was able to successfully fill the combo box with the
categories. Unfortunately, the scope of the Categories collection of the
NameSpace object is too broad, and doesn't include the custom categories
that
I have set for each calendar. Apparently, neither the MAPIFolder object
or
Items object have a Categories collection.

Is there anyway to get the custom categories without having to add an
appointment item?

TIA

Graham Mandeno said:
Hi JoD

I think you are confusing three things here:

1. The Categories collection, which is a property of the NameSpace, and
which contains the master list of all registered categories.

2. The Categories property of an OutlookItem, which is a comma-separated
string listing the categories applied to that item.

3. The Category property, which applies to the FormDescription object and
has nothing to do with what you want.

You can use the Categories collection to populate a RowSource of a combo
or
listbox (I suggest a multi-select listbox, because you can apply multiple
categories to an appointment). Something like this:

With olkNameSpace.Categories
For i = 1 to .Count
lstCategories.AddItem .Item(i)
Next i
End With

You may wish to read them into an array and sort them alphabetically.

Then, you can construct a comma-separated list of the selected categories
in
a string variable and assign it to the Categories property of the
AppointmentItem after you have created the item and before you save it:

Set olkApt = olkFolder.Items.Add(olAppointmentItem)
with olkApt
.Start = ...
.End = ...
...
.Categories = strCategoryList
.Save
End With

--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand


I would like to be able to, when the user chooses (from a combo box on
the
form) the calendar to which the appointment will be added, display the
current choices of categories for the calendar, have the user select
the
appropriate category, and then click "Add to Outlook" to add the
appointment,
complete with the desired category color.

The problem is that the Categories property is associated with the
AppointmentItem object and to retrieve it, I would have to add the
item. I
don't want to add the item until all information has been gathered.
Then,
if
I understand correctly, in order to set the particular category that is
chosen, that I will need to reference the "category" property of a
FormsDescription object that is asssociated with AppointmentItem
object.

I have the code in place to add the appointment item and have
successfully
tested it with the ability to choose the calendar.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top