DonationCoder.com Software > Post New Requests Here
IDEA - AHK script - Outlook'03 Apply Category Label
wideeyedguy:
As they say in Swahili - you are a beautiful person!
Jiffy spiffy; works perfectly.
I just reattached new command buttons pointing to
the new macro and done.
Sorry to get you so involved in creating the other code.
How can I unload the 'Virtua' toolbar from Outlook's 'memory'?
It's still showing up in available toolbars even though I've deleted
it off of the GUI.
Thanks.
r0bertdenir0:
If it's still available then I don't think you deleted it from the GUI, maybe just closed it?
Open the Customize Toolbars dialog, in the list of toolbars, click on Virtua & then click the Delete button on the right. :Thmbsup:
wideeyedguy:
Thank you.
We're done with this one.
weg
PRICET:
If it's still available then I don't think you deleted it from the GUI, maybe just closed it?
Open the Customize Toolbars dialog, in the list of toolbars, click on Virtua & then click the Delete button on the right. :Thmbsup:
-r0bertdenir0 (April 30, 2009, 07:41 AM)
--- End quote ---
Hi - I like this code. I created a couple of buttons on the Outlook toolbar and created 2 macros for 2 categories I use regularily.
However ..... if I hit one botton it inserts the category I coded. If I then hit the other button it overwrites the first category. Is there an aasy way of inserting the second category after "," i.e Category1, Category 2
Thanks
r0bertdenir0:
Try this
Option Explicit
Private Const MY_CUSTOM_CATEGORIES_1_ = "1 - Client - sent to"
Private Const MY_CUSTOM_CATEGORIES_2_ = "2 - Supplier"
Private Const MY_CUSTOM_CATEGORIES_3_ = "Test Category"
Public Sub Button1()
SetCustomCategoriesForItems MY_CUSTOM_CATEGORIES_1_
End Sub
Public Sub Button2()
SetCustomCategoriesForItems MY_CUSTOM_CATEGORIES_2_
End Sub
Public Sub Button3()
SetCustomCategoriesForItems MY_CUSTOM_CATEGORIES_3_
End Sub
Private Sub SetCustomCategoriesForItems(NewCategory As String)
On Error Resume Next
Dim oItem As Object
Err.Clear
'**first check if a single mail item is open 4 viewing & deal with that case first
If (ActiveWindow.Class = ActiveInspector.Class) Then
'**get the item we're viewing
Set oItem = ActiveInspector.CurrentItem
'**set their categories if they have the property
oItem.Categories = AddCategoryToCategories(NewCategory, oItem.Categories)
End If
If (ActiveWindow.Class = ActiveExplorer.Class) Then
'**loop thru selected items
For Each oItem In ActiveExplorer.Selection
'**clear the error buffer here in case the are mail items mixed with other items in folder - also the call to ActiveInspector.Class above has caused an error
Err.Clear
'**set their categories if they have the property
oItem.Categories = AddCategoryToCategories(NewCategory, oItem.Categories)
'**save our change
If (Err = 0) Then
oItem.Save
End If
Next oItem
End If
End Sub
Private Function AddCategoryToCategories(NewCategory As String, ExistingCategories As String) As String
Dim avExistingCategories
Dim vCategory
If (ExistingCategories = "") Then '**1st category is easy
AddCategoryToCategories = NewCategory
Else
'**split the category list
avExistingCategories = Split(ExistingCategories, ",")
'**search 4 match - this is slower but more robust than using InStr to search, but unless you hundreds of items with dozens of categories, you won't feel it
For Each vCategory In avExistingCategories
If (NewCategory = Trim(vCategory)) Then
AddCategoryToCategories = ExistingCategories
Exit Function
End If
Next vCategory
'**append the new item since it doesn't exist
AddCategoryToCategories = ExistingCategories & ", " & NewCategory
End If
End Function
--- End quote ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version