Set Categories macro

  • Thread starter Thread starter info
  • Start date Start date
I

info

This macro should add specified categorie to each email I have
selected, but nothing happens. What could be wrong?

/Marcus

----------------------------------------
Sub SetCategories()
' Set "Local" Category to email
Dim myItem As Object
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
NewCategories = InputBox("Specify Category new categorie", "Specify
Category...", "Miscellaneous")
On Error Resume Next
'Work on selected items
Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection
'For all items do...
For Each myItem In myOlSel
'Set categories
myItem.Categories = myItem.Categories & ";" & NewCategories
myItem.Save
Next
'Free variables
Set myItem = Nothing
Set myOlApp = Nothing
Set myOlExp = Nothing
Set myOlSel = Nothing
End Sub
----------------------------------------
 
If you have a problem with a macro it's always a good idea to comment out
any On Error Resume Next statement and see where any errors happen or what's
going on line by line.

Your code worked here when I added a Dim statement for NewCategories as a
string and replaced "myOlApp" with "Application". When writing Outlook VBA
code always use the intrinsic Application object for Outlook.Application.
 
Back
Top