L
lynxwoman
I have the book Microsoft Outlook Programming by Sue Mosher. I have
written the macro to replace one category with another.
I'm having trouble getting it to work. I use a custom for that requires
at least 2 categories to be selected (also from Sue Mosher).
Here's what my code looks like:
Sub ReplaceCat()
Dim objApp As Outlook.Application
Dim objFolder As Outlook.MAPIFolder
Dim objItem As Object
Dim arr() As String
Dim strOldCat As String
Dim strNewCat As String
Dim I As Integer
strOldCat = " "
strNewCat = "RTP Office"
Set objApp = CreateObject("Outlook.Application")
Set objFolder = objApp.ActiveExporer.CurrentFolder
For Each objItem In objFolder.Items
arr() = Split(objItem.Categories, ",")
For I = 0 To UBound(arr)
If arr(I) = strOldCat Then
arr(I) = strNewCat
Exit For
End If
Next
objItem.Categories = Join(arr, ",")
'objItem.Save
Next
Set objApp = Nothing
Set objFolder = Nothing
Set objItem = Nothing
End Sub
Any words to the unwise are appreciated
Thank you so much,
Sandy
written the macro to replace one category with another.
I'm having trouble getting it to work. I use a custom for that requires
at least 2 categories to be selected (also from Sue Mosher).
Here's what my code looks like:
Sub ReplaceCat()
Dim objApp As Outlook.Application
Dim objFolder As Outlook.MAPIFolder
Dim objItem As Object
Dim arr() As String
Dim strOldCat As String
Dim strNewCat As String
Dim I As Integer
strOldCat = " "
strNewCat = "RTP Office"
Set objApp = CreateObject("Outlook.Application")
Set objFolder = objApp.ActiveExporer.CurrentFolder
For Each objItem In objFolder.Items
arr() = Split(objItem.Categories, ",")
For I = 0 To UBound(arr)
If arr(I) = strOldCat Then
arr(I) = strNewCat
Exit For
End If
Next
objItem.Categories = Join(arr, ",")
'objItem.Save
Next
Set objApp = Nothing
Set objFolder = Nothing
Set objItem = Nothing
End Sub
Any words to the unwise are appreciated
Thank you so much,
Sandy