Making it hard to create uncategorized items in Outlook

Making it hard to create uncategorized items in Outlook

03-30-2005, 08:43 AM

Is there a macro/add-in/hidden function in Outlook that can keep you from creating uncategorized tasks, contacts, etc.? A VBA script that brings up a dialog box saying "categorize me!" when you attempt to close the window and save the record without adding a category to the item seems like it would be trivial to code (if I knew anything about VBA).

Or preferably: after you try to save something uncategorized, the macro automatically displays a pick list of categories, and saves the record once at least one category has been chosen for it? It seems like it would be easy to implement, and it surprises me that there's nothing readily available in Outlook to do this (or if there is, it surprises me how well they've hidden it!).

This is a crappy, quick-and-dirty version. Keep in touch and I'll send you a better one.

-------------------------------
Just put the code below into a vba module, then run the OutlookCleanup macro, assign it to a button, or whatever. I've got it set to check overall for category goodness.

Public Function CheckCategory(ByVal psCategory As String) As Boolean
Static cCategories As Collection
Dim sCategory As Variant

If IsEmpty(cCategories) = False Then
Set cCategories = GetMasterCategoryList
End If
CheckCategory = False
For Each sCategory In cCategories
If psCategory = sCategory Then
CheckCategory = True
Exit For
End If
Next
End Function

Public Function GetMasterCategoryList() As Collection
Dim cCategories As New Collection
Dim vCategories As Variant
Dim oWSHShell As Object
Dim sCategoryList As String
Dim i As Long
Dim sCategories() As String

'read the categories from the registry
'remember: it's unicode
Set oWSHShell = CreateObject("WScript.Shell")
vCategories = oWSHShell.RegRead("HKEY_CURRENT_USER\Software\Micr osoft\Office\11.0\Outlook\Categories\MasterList")
For i = 0 To UBound(vCategories)
If i Mod 2 = 0 Then
sCategoryList = sCategoryList + Chr(vCategories(i))
End If
Next
Debug.Print
sCategories = Split(sCategoryList, ";")
For i = 0 To UBound(sCategories)
cCategories.Add sCategories(i), sCategories(i)
Next
Set GetMasterCategoryList = cCategories
End Function

Comment

Thanks for your help! Should this work alright with Outlook 2000? I've modified where it's looking for the registry key (to 9.0 instead of 11.0), and keep getting a type mismatch error when the script gets to UBound(vCategories).

I'll have to try this out on my wife's office computer (running Office 2003) and see how it works...