C
Chris Quayle
Hi,
I need to create a macro that will clear filters from the current view. I
believe that this should be achieved by manipulating the xml. I started out
with the following:
Sub clearFiltersCurrentView()
Dim strXML As String
Dim intFilterStart As Integer
Dim intFilterEnd As Integer
strXML = Application.ActiveExplorer.CurrentView.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
Application.ActiveExplorer.CurrentView.XML = strXML
End Sub
Unfortunately, even though my strXML appears valid XML it doesn't seem to
remove the filter info from the XML of the current view. I have tried various
other methods to no avail. A simple line such as:
Application.ActiveExplorer.CurrentView.XML =
replace(Application.ActiveExplorer.CurrentView.XML,"UK","France")
works perfectly in changing the filter keyword from UK to France. However I
can't work out how to remove the filter altogether.
I've also noticed that if I apply a filter to a view, remove it and then
examine the output of Application.ActiveExplorer.CurrentView.XML the filter
information is still there even though it is not active. It also tends to
move to a different line in the XML (although my understanding is that this
makes no difference). It's as if there's another variable in the XML that
tells the view whether to apply the filter but I can't find it.
Please help!
I need to create a macro that will clear filters from the current view. I
believe that this should be achieved by manipulating the xml. I started out
with the following:
Sub clearFiltersCurrentView()
Dim strXML As String
Dim intFilterStart As Integer
Dim intFilterEnd As Integer
strXML = Application.ActiveExplorer.CurrentView.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
Application.ActiveExplorer.CurrentView.XML = strXML
End Sub
Unfortunately, even though my strXML appears valid XML it doesn't seem to
remove the filter info from the XML of the current view. I have tried various
other methods to no avail. A simple line such as:
Application.ActiveExplorer.CurrentView.XML =
replace(Application.ActiveExplorer.CurrentView.XML,"UK","France")
works perfectly in changing the filter keyword from UK to France. However I
can't work out how to remove the filter altogether.
I've also noticed that if I apply a filter to a view, remove it and then
examine the output of Application.ActiveExplorer.CurrentView.XML the filter
information is still there even though it is not active. It also tends to
move to a different line in the XML (although my understanding is that this
makes no difference). It's as if there's another variable in the XML that
tells the view whether to apply the filter but I can't find it.
Please help!