PDA

View Full Version : Categories Help



Zyhin
05-21-2014, 03:38 PM
Hi all,

I have been slowly learning VBA in Excel when I get the free time, but this is my first venture into Outlook.

I currently have set up Categories for priority. Eg. 1st Priority, 2nd Priority, 3rd Priority and so on up to 10th, and a category for not sorted emails. Is there a way that I can run a macro to change the priority up one (eg. 2nd now becomes 1st) as I deal with the 1st emails. If so, could some one please help me in the direction of a tutorial or code and some explanation of the code.

Thanks in advance.

westconn1
05-22-2014, 03:27 AM
you can test this to see if it does as you want

Dim myitem As MailItem, f As MAPIFolder
Set f = ActiveExplorer.CurrentFolder
For Each myitem In f.Items
cats = Split(myitem.Categories, ",")
For i = 0 To UBound(cats)
If InStr(cats(i), "Priority") > 0 Then
Select Case Split(cats(i))(0)
Case "2nd": Split(cats(i))(0) = "1st"
Case "3rd": Split(cats(i))(0) = "2nd"
Case "4th": Split(cats(i))(0) = "3rd"
Case Else: cats(i) = Val(cats(i)) - 1 & Mid(cats(i), 1 + Len(CStr(Val(cats(i)))))
End Select

End If
Next
myitem.Categories = Join(cats, ",")
Nextruns without error, but results untested