I am trying to change a task category using a macro by opening the categories dialog box while in the task and have it automatically change the name and mark it complete..
I've started some code, but I can't get anything to work. Any help is appreciated
Public Sub TagCompleted()
Dim objOutlook As Outlook.Application
Dim objInspector As Outlook.Inspector
Dim strDateTime As String
' Instantiate an Outlook Application object.
Set objOutlook = CreateObject("Outlook.Application")
' The ActiveInspector is the currently open item.
Set objExplorer = objOutlook.ActiveExplorer
' Check and see if anything is open.
If Not objExplorer Is Nothing Then ' Get the current item.
Dim arySelection As Object
Set arySelection = objExplorer.Selection
For x = 1 To arySelection.Count
strCats = arySelection.Item(x).ShowCategoriesDialogue
If Not strCats = "" Then
strCats = strCats & ","
End If
strCats = strCats
arySelection.Item(x).Categories = strCats
arySelection.Item(x).Completed
arySelection.Item(x).Save
Next x
Else ' Show error message with only the OK button.
MsgBox "No explorer is open", vbOKOnly
End If ' Set all objects equal to Nothing to destroy them and
' release the memory and resources they take.
Set objOutlook = Nothing
Set objExplorer = Nothing
End Sub
I've started some code, but I can't get anything to work. Any help is appreciated
Public Sub TagCompleted()
Dim objOutlook As Outlook.Application
Dim objInspector As Outlook.Inspector
Dim strDateTime As String
' Instantiate an Outlook Application object.
Set objOutlook = CreateObject("Outlook.Application")
' The ActiveInspector is the currently open item.
Set objExplorer = objOutlook.ActiveExplorer
' Check and see if anything is open.
If Not objExplorer Is Nothing Then ' Get the current item.
Dim arySelection As Object
Set arySelection = objExplorer.Selection
For x = 1 To arySelection.Count
strCats = arySelection.Item(x).ShowCategoriesDialogue
If Not strCats = "" Then
strCats = strCats & ","
End If
strCats = strCats
arySelection.Item(x).Categories = strCats
arySelection.Item(x).Completed
arySelection.Item(x).Save
Next x
Else ' Show error message with only the OK button.
MsgBox "No explorer is open", vbOKOnly
End If ' Set all objects equal to Nothing to destroy them and
' release the memory and resources they take.
Set objOutlook = Nothing
Set objExplorer = Nothing
End Sub