我想根据项目中的文本标记具有特定类别的项目。
我有以下代码。
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
我选择文件夹,然后运行宏,但它不会标记类别。
最佳答案
您需要.Save
您更新类别后的项目。下面是您保存的 For 循环。作为旁注,请记住,您会将任何现有类别覆盖为 .Categories
是一个逗号分隔的字符串。您可能想测试是否 .Categories
为空,如果不是,请添加“,重要”。
For Each objItem In objList
If (InStr(objItem.Body, "(WA)") > 0) Then
objItem.Categories = "Important"
objItem.Save
If (InStr(objItem.Categories, "Important") > 0) Then
iCount = iCount + 1
End If
End If
Next
关于vba - 使用特定类别标记项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7439187/