I want to mark an item with a particular category, based on the text within the item.
I have the following code.
Sub ProcessRSS()
' Read RSS items and process the usful ones.
Dim objList As Object
Dim objItem As Object
Dim iCount As Integer
Set objList = Application.ActiveExplorer.CurrentFolder.Items
iCount = 0
For Each objItem In objList
If (InStr(objItem.Body, "(WA)") > 0) Then
objItem.Categories = "Important"
If (InStr(objItem.Categories, "Important") > 0) Then
iCount = iCount + 1
End If
End If
Next
Debug.Print "Marked " & iCount & " RSS Items as important."
End Sub
I select the folder and then run the macro, but it won’t mark the category.
You need to
.Saveyour item after you update the category. Below is your For loop with the save. As a side note, keep in mind that you’ll be overwriting any existing categories as.Categoriesis a comma-delimited string. You may want to test if.Categoriesis empty and, if not, add “, Important”.