Issue with active sheet and active cell display

Version: (x64) / LibreOffice Community
Build ID: a529a4fab45b75fefc5b6226684193eb000654f6
CPU threads: 8; OS: Windows 6.1 Service Pack 1 Build 7601; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL

I found the following code and applied it to what I am doing, and it works great with one exception. The code shows sheet name and currently selected cell on all sheets, except for the first one, where it shows only the cell coordinates. It is by design, or is it a bug?

Sub Main
    	dim oActiveCell as object
    	dim oConv as object
    	oActiveCell = ThisComponent.getCurrentSelection()
    	oConv = ThisComponent.createInstance("")
    	oConv.Address = oActiveCell.getCellAddress
    	msgbox oConv.UserInterfaceRepresentation
End Sub

Thank you in adnvace for all your help.

I can reproduce the described mis(?)behaviour with V, and would see it as a bug.
However, the code has too many flaws (expectable malfunctioning) anyway.

The “ActiveCell” is a VBA concept, and it’s basically different from the CurrentSelection as handled by the LibO API. Only if you can assure that no additional cells (or ranges) can be selected, the CurrentSelction of a spreadsheet document will return the active cell (the cell currently having the keyboard focus) as CurentSelection even if it not is actually selected.

If cells or ranges are selected, the focused cell can be an additional cell not selected and highlighted itself, but only visualized by a frame around the cell’s area. After having selected cells or ranges, you can give the focus to an additional cell by Ctrl+Click once and a second time on the same cell. You can also Ctrl+Click on a previously selected cell and this way put the focus on it and remove it from the selection at the same time.

If you actually want advice how to get a specific representation of the current focus-cell, please edit your question telling so.

If you want to wait for a bugfix, report the bug to . Stay aware of the fact that the no-single-cell-selection will cause an error anyway with your code.

Generally: Don’t think Excel-VBA if you want to program in Basic for LibreOffice Calc. If you insist on the usage of VBA concepts against advice, you may try your code drafts with Option VBAsupport 1 and/or Option Compatible. This way VBA-like code will run in some cases, but in others it will not. Don’t expect to find many experienced helpers here in this case. VBA support is still partly experimental.

Thank you very much for this elaborate explanation. The “misbehaviour” has an easy workaround, which is not a big deal. Nevertheless, I think it’s worth reporting for the programmers to analyze and decide whether this is by design or needs to be corrected.