FIltering Contacts Folder

C

Chad Gartner

Hi, I'm trying to figure out how to filter the card view list of
contacts on the main outlook window from a button within a custom form.
Right now it displays a whole new window with the contacts folder (i'd
like the current one to refresh ideally), but doesn't restrict by what I
want restricted. Do I have to use OVC in a custom window to do something
like this? I've searched the MSDN and outlook code site but havn't run
across anything similar, nor do I recall anything in my Outlook
Programming book.

Secondly, does anyone have a good reccomendation for a better
understanding of the object-oriented basis for programming in VB? I
understand most of the methods I know, I just usually have a tough time
knowing what other 1-5 things need to be initialized before you get
there. (I stink at object oriented programming I think.)
Thanks for looking!

-Chad

Here's my modified MS code for reference.

Sub ContactsByCategory()
' This procedure returns an Outlook ContactItem that matches the
' criteria specified in the arguments passed to the procedure.
Dim fldFolder As Outlook.MAPIFolder
Dim objItemsCollection As Object
Dim objItem As Object
Dim objMatchingItem As Object
Dim strCriteria As String

On Error GoTo GetItem_End

' Use the InitializeOutlook procedure to initialize global
' Application and NameSpace object variables, if necessary.
If gobjApp Is Nothing Then
If InitializeOutlook = False Then
MsgBox "Unable to initialize Outlook Application " & "or
NameSpace object variables!"
Exit Sub
End If
End If

Set fldFolder = gnspNameSpace.GetDefaultFolder(olFolderContacts)

strCriteria = "[Categories] = 'Legal'"

Set objItemsCollection = fldFolder.Items.Restrict(strCriteria)

If objItemsCollection.Count > 0 Then
fldFolder.Display
End If

GetItem_End:
Exit Sub
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
S

Sue Mosher [MVP-Outlook]

Restrict does not affect the UI.

You didn't mention your Outlook version. If you're using OL2002 SP2 or
later, you can modify the <filter> element of the View.XML property.
Otherwise, you'd need to use the OVC in a folder home page.
 

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