		if theSelection.SupportsService("com.sun.star.sheet.SheetCell")  then
			' SINGLE CELL SELECTED
			theCell=theSelection
			msgbox "1/A Selected cell: " + theCell.RangeAddress.StartColumn + ":" + theCell.RangeAddress.StartRow
			oActiveCell = ThisComponent.getCurrentSelection()
			oConv = ThisComponent.createInstance("com.sun.star.table.CellAddressConversion")
			oConv.Address = oActiveCell.getCellAddress
			msgbox "1/B Cell Address: " + oConv.Address.Column + ":" + oConv.Address.Row
		end if
		if theSelection.SupportsService("com.sun.star.sheet.SheetCellRange")  then
			' RANGE OF CELLS SELECTED OR SINGLE CELL SELECTED
			msgbox 	"2 Selected cell in a range: " + theSelection.RangeAddress.StartColumn + ":" + theSelection.RangeAddress.StartRow + " - " + _
					theSelection.RangeAddress.EndColumn + ":" + theSelection.RangeAddress.EndRow
		end if
		activeSheet = ThisComponent.getCurrentController.getActiveSheet
		theCell = UsedRange(activeSheet)
		msgbox 	"Used range: " + theCell.RangeAddress.StartColumn + ":" + theCell.RangeAddress.StartRow + " - " + _
				theCell.RangeAddress.EndColumn + ":" + theCell.RangeAddress.EndRow + "; " + _
				theCell.AbsoluteName

Function UsedRange(oSheet As Variant) As Variant
	REM https://ask.libreoffice.org/t/looking-for-last-row-used-programmatically/26223/5
	Dim oCursor As Variant
	oCursor = oSheet.createCursor()
	oCursor.gotoEndOfUsedArea(False)
	oCursor.gotoStartOfUsedArea(True)
	UsedRange = oCursor
End Function