sub resultat ()
Dim oSheet 'A sheet from the Calc document.
Dim oRanges 'The NamedRanges property.
Dim oCritRange 'Range that contains the filter criteria.
Dim oDataRange 'Range that contains the data to filter.
Dim oFiltDesc 'Filter descriptor.
REM Range that contains the filter criteria
oSheet = ThisComponent.getSheets().getByIndex(1)
oCritRange = oSheet.getCellRangeByName("E1:E2")
REM The data that I want to filter
oSheet = ThisComponent.getSheets().getByIndex(0)
oDataRange = oSheet.getCellRangeByName("A1:C7")
oFiltDesc = oCritRange.createFilterDescriptorByObject(oDataRange)
oDataRange.filter(oFiltDesc)
REM Copy the output data rather than filter in place.
oFiltDesc.CopyOutputData = True
REM Create a CellAddress and set it for Sheet3,
REM Column B, Row 4 (remember, start counting with 0)
Dim x As New com.sun.star.table.CellAddress
x.Sheet = 2
x.Column = 1
x.Row = 3
oFiltDesc.OutputPosition = x
End Sub
sub resultat ()
Dim oSheet 'A sheet from the Calc document.
Dim oSheetcri 'A sheet from the Calc document.
Dim oRanges 'The NamedRanges property.
Dim oCritRange 'Range that contains the filter criteria.
Dim oDataRange 'Range that contains the data to filter.
Dim oFiltDesc 'Filter descriptor.
REM Range that contains the filter criteria
oSheetcri = ThisComponent.getSheets().getByIndex(1)
oCritRange = oSheetcri.getCellRangeByName("E1:E2")
REM The data that I want to filter
oSheet = ThisComponent.getSheets().getByIndex(0)
oDataRange = oSheet.getCellRangeByName("A1:C7")
oFiltDesc = oCritRange.createFilterDescriptorByObject(oDataRange)
REM Copy the output data rather than filter in place.
oFiltDesc.CopyOutputData = True
REM Create a CellAddress and set it for Sheet3,
REM Column B, Row 4 (remember, start counting with 0)
Dim x As New com.sun.star.table.CellAddress
x.Sheet = 2
x.Column = 1
x.Row = 3
oFiltDesc.OutputPosition = x
oDataRange.filter(oFiltDesc)
End Sub
Men det giver fejlen objektvariablen kunne ikke init.. i linien
oFiltDesc.CopyOutputData = True
Flytter jeg linien oDataRange.filter(oFiltDesc)
op over oFiltDesc.CopyOutputData = True
Umiddelbart kan jeg ikke se fejl, og det virker her. Hvis den ikke kan initiere
'oFiltDesc.CopyOutputData = True' vil den foretage filtreringen i hovedtabellen på ark1 (Filtrerer du på en allerede filtreret tabel?)
' oDataRange.filter(oFiltDesc)' skal stå efter alle parametrene er defineret.
Se mit eksempel http://dl.dropbox.com/u/2601866/standar ... 0makro.ods