Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Flims, Switzerland
    Posts
    271
    Thanks
    0
    Thanked 0 Times in 0 Posts

    show/hide completed items (2000 SP3)

    Is there any way to show/hide completed task items in the current view using VBA?

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: show/hide completed items (2000 SP3)

    Views aren't very well exposed even in 2003 and neither are Filters (the Outlook VBA Filter Method doesn't seem to work the same as the Filters available under View). The only approach I can think of is if you create and name two Task views, such as "ShowAllTasks" and "ShowCompletedTasks", and then have code something like this (untested, and plagiarized from Jefferson):

    Sub settaskview()
    Dim olNS As Outlook.NameSpace
    Dim fldrTasks As Outlook.MAPIFolder

    On Error Resume Next
    Set olNS = Application.GetNamespace("MAPI")
    ' assuming only the default task folder is in use
    Set fldrTasks = olNS.GetDefaultFolder(olFolderTasks)

    With fldrTasks
    If .CurrentView = "ShowAllTasks" Then
    .CurrentView = "ShowCompletedTasks"
    Else
    .CurrentView = "ShowAllTasks"
    End If
    .ShowPane olPreview, False
    .Display
    End With

    Set fldrTasks = Nothing
    Set olNS = Nothing
    End Sub
    -John ... I float in liquid gardens
    UTC -7ąDS

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Flims, Switzerland
    Posts
    271
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: show/hide completed items (2000 SP3)

    John, thanks a lot for the reply. I actually thought of exactly the same solution just after I wrote the post. I'm currently using this:-
    <pre>Sub ShowHideCompletedTasks_Click()
    If ActiveExplorer.CurrentView = "By Category" Then
    ActiveExplorer.CurrentView = "By Category Pending"
    Else
    ActiveExplorer.CurrentView = "By Category"
    End If
    End Sub</pre>

    which seems to work fine. I do, however, still wonder if there is a way to actually change the definition of the view programatically. I've scoured the object model but still can't find anything.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •