Ask Your Question

reset autofilter with button? [closed]

asked 2013-01-31 17:21:09 +0200

curmet gravatar image

updated 2014-07-05 21:08:59 +0200

manj_k gravatar image

Is there a way to reset a AutoFilter in calc with an big Button. I think there would be a way with Basic but i didn´t find a good tutorial. I tried to record a "makro" but with no success.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2015-10-21 02:26:34.470763

1 Answer

Sort by » oldest newest most voted

answered 2013-01-31 22:17:08 +0200

w_whalley gravatar image

I don't know why your macro recording failed. I was able to record a macro to set up the autofilter and another one to remove it. They were the same code, so it must be a toggle. I recorded a third macro to select the head of the autofilter, cell A1, and putting it all together this is what I came up with.

sub toggle
dim document   as object
dim dispatcher as object
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("")
dim args1(0) as new
args1(0).Name = "ToPoint"
args1(0).Value = "$A$1"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
dispatcher.executeDispatch(document, ".uno:DataFilterAutoFilter", "", 0, Array())
end sub

I hooked the toggle macro to a button using the button control Mouse button pressed event. Clicking on the button toggles to autofilter on or off.

edit flag offensive delete link more

Question Tools


Asked: 2013-01-31 17:21:09 +0200

Seen: 430 times

Last updated: Jan 31 '13