Set Categories macro

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
----------------------------------------
 
K

Ken Slovak - [MVP - Outlook]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top