-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I tried to enable the autofilter feature for a named range using oo api ...
First I recorded the following macro:

- --------------------------8<------------------------
Sub DataFilter()
        Dim oDoc as Object
        Dim dispatcher as Object
        Dim args1(0) as new com.sun.star.beans.PropertyValue

        oDoc = ThisComponent.CurrentController.Frame
        dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
        
        ' select and mark data via named range ...
        args1(0).Name = "ToPoint"
        args1(0).Value = "X_FILTERAREA"
        dispatcher.executeDispatch(oDoc, ".uno:GoToCell", "", 0, args1())

        ' enable/disable autofilter ...
        dispatcher.executeDispatch(oDoc, ".uno:DataFilterAutoFilter", "", 0, 
Array())
End Sub
- -------------------------->8------------------------

It works, but it is not what i really wanted ....
Second i created the following code snippet, using a temporary database range 
...

- --------------------------8<------------------------
OPTION EXPLICIT

Sub EnableAutoFilter()
        Call ApplyAutoFilter(ThisComponent, "X_FILTERAREA", True)
End Sub

Sub DisableAutoFilter()
        Call ApplyAutoFilter(ThisComponent, "X_FILTERAREA", False)
End Sub

Sub ApplyAutoFilter(oDocument as Object, ByVal sNamedRange as String, ByVal 
bEnabled as Boolean)

        Dim oRangeAddress as Object
        Dim sDatabaseRange as String

        sDatabaseRange = "TmpFilterArea"

        If oDocument.DatabaseRanges.hasByName(sDatabaseRange) Then
                If bEnabled = False Then
                        
oDocument.DatabaseRanges.getByName(sDatabaseRange).AutoFilter = False
                EndIf
                oDocument.DatabaseRanges.removeByName(sDatabaseRange)
        EndIf

        If bEnabled = True and oDocument.NamedRanges.hasByName(sNamedRange) Then
                oRangeAddress = 
oDocument.NamedRanges.getByName(sNamedRange).getReferredCells().getRangeAddress()
                oDocument.DatabaseRanges.addNewByName(sDatabaseRange, 
oRangeAddress)
                oDocument.DatabaseRanges.getByName(sDatabaseRange).AutoFilter = 
True
        EndIf
End Sub
- -------------------------->8------------------------

But is there no easier way to enable/disable an autofilter for a range ?
And is it possible to find out, if an autofilter is enabled ?

Oliver

- --

GnuPG key 0xCFD04A45: 8822 057F 4956 46D3 352C 1A06 4E2C AB40 CFD0 4A45
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFD+gd4TiyrQM/QSkURAvO6AKDGOZI46q6hogH6Gt5SybSiMr+QCACgmo3J
7IbxcS0aqsai8uWuhTEDTnc=
=nGH9
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to