How can I get the coordinates of the OnFocused Cell?

sub main()

Dim Current_Sheet As String
oSheet = ThisComponent.CurrentController.ActiveSheet    
oActiveCell = ThisComponent.getCurrentSelection
Cell_r = oActiveCell.RangeAddress.StartRow
Cell_c = oActiveCell.RangeAddress.StartColumn

end sub

In multiple cell selection, when the selected cells are A1:C3 and the cell C3 is active(OnFocus), then

[RangeAddress] - StartRow: 0, StartColumn: 0, EndRow: 2, EndColumn 2.

But I only want to know the coordinates of the active cell(in this case, “C3”) that I clicked first.

How can I get it?

Thank you for your help.

Sorry. Just found that you had posted this question again as a duplicate. What good for? Would you mind to read about forum manners?

I’m so sorry. I don’t know well how to use this site yet. It seems so slow. And I’m still learning. I shall be careful hereafter.

Sorry. I was too harsh. Anyway I would like to know if my example was helpful, and also for what purpose the knowledge about ActiveCell position is needed.
It’s not a new fact that Calc does not support this generously, and after all most users, even those who sometimes write some lines of code, get along with things as they are.

(I hadn’t noticed this as a duplicate in time. Thus I suspected the askbot to have killed my previous answer. Having added an attachment here, I will not delete this answer despite the fact that posting duplicates should not be encouraged.)

The ActiveCell does not occur in the LibreOffice (Calc) API as a concept. It does exist in a sense like “the cell that will be edited if F2 is pressed or if the formula bar is entered” or “the cell that has an emphasizing border in the view”. However, this cell is not assured to be in the CurrentSelection, and if it is, it may not be the topmost leftmost of any one of the single ranges contained therein.
Moreover the CurrentSelection can be multirange, and then not supporting the service “com.sun.star.sheet.SheetCellRange”, not to mention “com.sun.star.sheet.SheetCell”.

If you urgently need to work with the ActiveCell in user code, I thus would suggest you set the Option VBAsupport 1 in LibO BASIC, and use the then as-if-predefined-variable ActiveCell.

As a matter of fact I do not know application cases for this.

How to do as I suggested you may learn from this attached example.

Editing: I did not take precautions against premature calls to the included user functions. Therefore you will get errors during the recalculation OnLoadDocument. As soon as the document is completely loaded a Ctrl+Shift+F9 will call a recalculation that should work.

Thanks to you, I’ve solved my problem completely. Thank you so much.