Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / November 2006

Tip: Looking for answers? Try searching our database.

Set Categories macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
info@flaxar.se - 20 Nov 2006 14:25 GMT
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
----------------------------------------
Ken Slovak - [MVP - Outlook] - 20 Nov 2006 15:45 GMT
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.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> This macro should add specified categorie to each email I have
> selected, but nothing happens. What could be wrong?
[quoted text clipped - 26 lines]
> End Sub
> ----------------------------------------
info@flaxar.se - 20 Nov 2006 16:51 GMT
Great! Works fine, thanks!
Justyn Case - 22 Nov 2006 17:13 GMT
On Mon, 20 Nov 2006 08:51:29 -0800, info wrote:

> Great! Works fine, thanks!

Could you post it again please?  I missed it first time round.

Justyn Case
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.