Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

selecting a cell in LibreOffice Calc

So I have a macro to clear some cells A2-A250 but I want to return to cell A1 once I have finished

Sub reset
Dim oActiveSheet As Variant
Dim oCellRangeByName As Variant

oActiveSheet = ThisComponent.getCurrentController().getActiveSheet()

oCellRangeByName = oActiveSheet.getCellRangeByName("A1:A250")

oCellRangeByName.clearContents(7)
End Sub
like image 659
OliverH Avatar asked Oct 16 '25 18:10

OliverH


1 Answers

To move to a cell, select it:

oRange = oActiveSheet.getCellRangeByName("A1")
ThisComponent.getCurrentController().Select(oRange)

Section 6.5.3 of Andrew Pitonyak's macro document discusses how to select a cell with or without the outline. Add this code to unhighlight the cell:

oRanges = ThisComponent.createInstance("com.sun.star.sheet.SheetCellRanges")
ThisComponent.getCurrentController().Select(oRanges)
like image 55
Jim K Avatar answered Oct 19 '25 13:10

Jim K