OutputPosition of AdvancedFilter is set.
When I reset the filter manually via the menu, all data is copied to the output range automatically, as if i called UnoResetFilter. How can I do this without a dispatcher?
<...>
Dim oFilterDsc As Object 'filter descriptor
oFilterDsc = oCriteriaRange.createFilterDescriptorByObject(oDataRange)
With oFilterDsc
.ContainsHeader = True
.CopyOutputData = True
.OutputPosition = oOutputPositionCell.CellAddress
.SaveOutputPosition = True
End With
oDataRange.filter(oFilterDsc)
<...>
Rem The sheet must be active. The active cell must be within the filtered range (data source).
Sub UnoResetFilter()
Dim document As Object, dispatcher As Object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:DataFilterRemoveFilter", "", 0, Array())
End Sub
<...>
oFilterDsc = oCriteriaRange.createFilterDescriptor(True) 'bEmpty:=True
oDataRange.filter(oFilterDsc)
<...>
The last 2 lines reset the filter (menu item: ‘Data - More Filters - Reset Filer’ turns gray), but all data is not copied to the output range.
During testing, the filter can be applied manually. You just need to reset it programmatically, but so that all data is copied to the output range.
UPDATED:
Or does the UNO method do this work, and I have to copy the data to the output range manually?
oSheet.copyRange(oOutputPositionCell.CellAddress, oDataRange.RangeAddress)
But resetting the filter also clears the results of the previous output. This means that I will have to do this myself. Do I understand correctly?
Then it is probably easier to use the UNO method…