Context: I am helping the reporter of this RFE by trying to create a macro for keyboard-assisted multiselection of cells.
Here is what I have put together based on the example in Andrew Pitonyak’s Macro book’s section 6.5.2
Sub RetrieveTheActiveCell()
Dim oOldSelection 'The original selection of cell ranges
Dim oRanges 'A blank range created by the document
Dim oActiveCell 'The current active cell
REM store the current selection
oOldSelection = ThisComponent.CurrentSelection
oRanges = ThisComponent.createInstance("com.sun.star.sheet.SheetCellRanges")
ThisComponent.CurrentController.Select(oRanges)
'get the active cell!
oActiveCell = ThisComponent.CurrentSelection
'add new selection to the old selection
oOldSelection.addRangeAddress(oActiveCell.getRangeAddress, False)
ThisComponent.CurrentController.Select(oOldSelection)
End Sub
This works in Calc’s “Adding” selection mode, but it would be great, if the cell focus did not jump to the top of the selection.
If I use uno:GoToCell at the end, it loses the selection.
Is there any way to preserve the focus in the original active cell?