OOo Basic macro language :
I would like to select / unselect a range of sheets in a spreadsheet document, by index or by name, to clear contents of a specific cellrange in each of selected sheet.
I tried to scan an array contained sheet's name concerned, but as I have 40 sheets and 120 ranges of cells to clear it's very too long to do.
Clear range of cells after had selected a list of sheets should be a quicker process.
Thanks for your answers.
select / unselect range of sheets
Re: select / unselect range of sheets
Code: Select all
n = thisComponent.Sheets.getCount()
Dim a(n -1) as new com.sun.star.table.CellRangeAddress
' B2:F1000 on each sheet:
For i = 0 to n -1
a(i).Sheet = i
a(i).StartColumn = 1
a(i).StartRow= 1
a(i).EndColumn = 5
a(i).EndRow = 999
next
oBasket = thisComponent.createInstance("com.sun.star.sheet.SheetCellRanges")
oBasket.addRangeAddresses(a(), False)
with com.sun.star.sheet.CellFlags
nWhat = .FORMULA + .STRING + .VALUE + .DATETIME
end with
oBasket.clearContents(nWhat)
Edit: I forgot the DATETIME flag. Calc keeps track of constant date/times due to the variable NullDate property. |
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice