Sorry, you´re right. Here it comes again. The sample assumes that there
are always two characters between two categories - I never have seen
anything else.
You can call the function e.g.:
With Application.ActiveExplorer.Selection(1)
.Categories=RemoveCategory(.Categories, "Mail")
.Save
End with
Private Function RemoveCategory(sCategories As String, sRemove As
String) As String
Dim lPos As Long
Dim lLenTotal As Long
Dim lLenRemove As Long
lLenTotal = Len(sCategories)
If lLenTotal Then
lLenRemove = Len(sRemove)
lPos = InStr(1, sCategories, sRemove, vbTextCompare)
Select Case lPos
Case 1
Select Case lLenTotal
Case Is > lLenRemove
sCategories = Trim$(Mid$(sCategories, lPos + Len(sRemove) + 1))
Case Else
sCategories = vbNullString
End Select
Case Is > 1
Select Case lLenTotal
Case Is > lPos + lLenRemove - 1
sCategories = left$(sCategories, lPos - 3) & _
Mid(sCategories, lPos + Len(sRemove))
Case Else
sCategories = left$(sCategories, lPos - 3)
End Select
End Select
End If
RemoveCategory = sCategories
End Function