Programmatic construction (macro) to make complex views on the fly

J

JIMBOLUKE

I really feel that the ability to specify filters in SQL is truly an enabling
feature in Outlook. My way of organizing tens of thousands of emails is to
actually leave them in one big folder (I start a new one each year), and to
use categories as tags. Categories is really a nice field because you can
assign multiple ones per message. I expose this field and sort by it in
message view, and it blows away (to me) the notion of making many neat little
folders and trying to figure out which one a message should go into (or
copying it multiple times into multiple folders). It's a real power method
for organizing messages, cause you can easily change, consolidate, and tweak
the categories of multiple messages very quickly. Imagine trying to do this
with folders, where you can really only see into them one folder at a time.

Often, even in this method, I need to narrow down my search. I can still
find > 1000 messages having a specific category, which I can sometimes deal
with by employing a secondary grouping, but I cannot sadly group by
categories within a grouping by categories (too much recursion I guess). Say
I want to find things having two categories, "NPS" and "AMES". I only have
one message with both categories, but I have > 500 messages that have NPS and
700 messages that have AMES. With the ability to customize a filter in
views using SQL, I can do something like this:

("urn:schemas-microsoft-com:eek:ffice:eek:ffice#Keywords" LIKE '%NPS%' AND
"urn:schemas-microsoft-com:eek:ffice:eek:ffice#Keywords" LIKE '%AMES%')

and this prunes away the clutter very quickly to the single one message that
related to both those category tags. In fact, that is the only way I can
quickly find those intersections.

SORRY FOR THE LONG PREAMBLE, but this is my zillion dollar question: Can we
use macros to define view filters on the fly? Instead of having to clumsily
click through a bunch of stuff to get to the filter dialog and type it in,
I'd like to get to the point of having quick-select macros that can help me
find things in a flash. No more clicking through pigeon-holed folders, I
can't go back at this point.

-jim
 
S

Sue Mosher [MVP-Outlook]

Yes, it can be done, but the details depend on your Outlook version, which
you should always include when posting to an Outlook forum.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

In Outlook 2007, it's easy: Return the view that you want to work with as a
TableView object, then set its Filter property to your query string. For
example:

Public Sub Filter1()
Dim strQuery As String
Dim vw As View
Dim tvw As TableView

strQuery = "(""urn:schemas-microsoft-com:eek:ffice:eek:ffice#Keywords"" LIKE
'%NPS%') " & _
"AND (""urn:schemas-microsoft-com:eek:ffice:eek:ffice#Keywords"" LIKE
'%AMES%')"

Set vw = Application.ActiveExplorer.CurrentView
If vw.ViewType = olTableView Then
Set tvw = vw
tvw.Filter = strQuery
tvw.Apply
End If

Set vw = Nothing
Set tvw = Nothing
End Sub
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
J

JIMBOLUKE

Thanks Sue, this is neat

Sue Mosher said:
In Outlook 2007, it's easy: Return the view that you want to work with as a
TableView object, then set its Filter property to your query string. For
example:

Public Sub Filter1()
Dim strQuery As String
Dim vw As View
Dim tvw As TableView

strQuery = "(""urn:schemas-microsoft-com:eek:ffice:eek:ffice#Keywords"" LIKE
'%NPS%') " & _
"AND (""urn:schemas-microsoft-com:eek:ffice:eek:ffice#Keywords"" LIKE
'%AMES%')"

Set vw = Application.ActiveExplorer.CurrentView
If vw.ViewType = olTableView Then
Set tvw = vw
tvw.Filter = strQuery
tvw.Apply
End If

Set vw = Nothing
Set tvw = Nothing
End Sub
 

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