P
PGT
Below i wrote code to assign a categorie to a calendar item based on the word "vrij" in the subject
I got to automate a lot of words for a lot of people so this just the first keyword
I think this code should work.. but somehow it doesn
I use Outlook 2003 with macro security set to lowest level. The code is placed in "this outlook session
Any ideas why it doesnt work ?
Dim WithEvents colRDVItems As Item
Private Sub Application_Startup(
Dim NS As Outlook.NameSpac
Set NS = Application.GetNamespace("MAPI"
Set colRDVItems = NS.GetDefaultFolder(olFolderCalendar).Item
Set NS = Nothin
End Su
Private Sub colRDVItems_ItemAdd(ByVal Item As Object
If Item.Class = olAppointment The
If InStr(LCase(Item.Subject), "vrij") > 1 The
AddCat Item, "Holiday
Item.Sav
End I
End I
End Su
Sub AddCat(itm, catName
arr = Split(itm.Categories, ","
If UBound(arr) >= 0 The
' item has categorie
For I = 0 To UBound(arr
If Trim(arr(I)) = catName The
' category already exists on ite
' no need to add i
Exit Su
End I
Nex
itm.Categories = itm.Categories & "," & catNam
Els
' item has no categorie
itm.Categories = catNam
End I
End Sub
I got to automate a lot of words for a lot of people so this just the first keyword
I think this code should work.. but somehow it doesn
I use Outlook 2003 with macro security set to lowest level. The code is placed in "this outlook session
Any ideas why it doesnt work ?
===================================================
Dim WithEvents colRDVItems As Item
Private Sub Application_Startup(
Dim NS As Outlook.NameSpac
Set NS = Application.GetNamespace("MAPI"
Set colRDVItems = NS.GetDefaultFolder(olFolderCalendar).Item
Set NS = Nothin
End Su
Private Sub colRDVItems_ItemAdd(ByVal Item As Object
If Item.Class = olAppointment The
If InStr(LCase(Item.Subject), "vrij") > 1 The
AddCat Item, "Holiday
Item.Sav
End I
End I
End Su
Sub AddCat(itm, catName
arr = Split(itm.Categories, ","
If UBound(arr) >= 0 The
' item has categorie
For I = 0 To UBound(arr
If Trim(arr(I)) = catName The
' category already exists on ite
' no need to add i
Exit Su
End I
Nex
itm.Categories = itm.Categories & "," & catNam
Els
' item has no categorie
itm.Categories = catNam
End I
End Sub