A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Remove filter from current view - outlook 2003



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5  
Old March 30th 09, 03:16 PM posted to microsoft.public.outlook.program_vba
Chris Quayle[_2_]
external usenet poster
 
Posts: 2
Default Remove filter from current view - outlook 2003

Thanks for your help. In the end I created a new view called 'Unfiltered
view' and applied strXML (with fliter text removed) to that view and loaded
it each time I want to clear fliters. Then I use a separate view 'Filtered
view' to be loaded every time I want to apply a filter and use macros to make
sure a filter never gets applied to Unfiltered.

"Ken Slovak - [MVP - Outlook]" wrote:

This isn't Outlook 2007 is it?

I'm not sure this idea will work:

Get the XML, Name, ViewType and SaveOption property values. Also capture the
LockUserChanges value. Change the current view to another of the views
available in the Views collection Then go up one level to the Views
collection and delete that view. Add your view with all the properties you
saved, using the Add() function. Then drop down to the View object you got
from Add() and set the view and apply and save it.

See if that does something for you.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Chris Quayle" wrote in message
...
Ken,

Thanks for confirming that removing the filter text is the correct way. I
had removed the save/apply lines because I've found that they are not
necessary when changing other aspects of the xml. I have now added them
and
my code still does not work. Code is as follows:
Sub clearFiltersCurrentView()

Dim strXML As String
Dim intFilterStart As Integer
Dim intFilterEnd As Integer
Dim vCurrentView As View

Set vCurrentView = Application.ActiveExplorer.CurrentView

strXML = vCurrentView.XML

intFilterStart = InStr(1, strXML, "filter", vbTextCompare)
intFilterEnd = InStr(1, strXML, "/filter", vbTextCompare)

Do While (intFilterStart 0 Or intFilterEnd 0)

If (intFilterStart = 0 Or intFilterEnd = 0) Then MsgBox "error"

strXML = Left(strXML, intFilterStart - 1) & Right(strXML, Len(strXML) -
(intFilterEnd - 1) - Len("/filter"))

intFilterStart = InStr(1, strXML, "filter", vbTextCompare)
intFilterEnd = InStr(1, strXML, "/filter", vbTextCompare)

Loop

If InStr(1, strXML, "sortdesc/sort", vbTextCompare) Then
strXML = Replace(strXML, "sortdesc/sort", "sortasc/sort")
Else
strXML = Replace(strXML, "sortasc/sort", "sortdesc/sort")
End If

Debug.Print strXML
vCurrentView.XML = strXML
vCurrentView.Save
vCurrentView.Apply
Debug.Print vCurrentView.XML
End Sub

I have added the step to toggle the sorting order to be sure that strXML
is
being applied and the column sorting in my outlook view is indeed
inverting
every time I run it. The Debug.Print strXML output verifies that there is
no
filter line in the new XML, however it persists in vCurrentView.XML even
after the changes are being applied. It's as if VBA will only change the
XML
for XML tags that you offer a replacement for but won't delete them.

So I'm still stuck!

Chris



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OUTLOOK 2003 - CALENDAR - COPYING appointments in Current View ACT Aloha Outlook - Calandaring 1 May 6th 08 08:36 AM
Programmatically setting a filter on a day/week/month view in Outlook 2003 sn Add-ins for Outlook 1 May 7th 07 02:36 PM
Outlook 2003 cannot remove Inbox filter Beemer Outlook - General Queries 1 January 25th 07 03:29 PM
"There are no items to show in this view" in Taskpad. No filter. Cant reset Current view [email protected] Outlook - Calandaring 0 February 3rd 06 06:36 PM
current & future calendar on monthly view outlook 2003 camsnanny Outlook - Calandaring 1 January 27th 06 10:28 PM


All times are GMT +1. The time now is 05:09 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.