In Libre Office Basic Macros, is there an equivalent function to the spreadsheet function column()?

In Libre Office Basic Macros, is there an equivalent function to the spreadsheet function column()?

I’ve been looking around all day using google, but all I can find are very complex multi-line “solutions” that sometimes I’m not even sure what they are solutions for.

Anyway… returning the column of the current cell has to be something very basic and common that I’m figuring there must be some function call in LO Basic already that returns this in a very straightforward manner.

My macro needs to make a decision based on the column of the currently-selected cell

Something like:

Do While column() = 3

Loop

(and BTW, the Captcha at the bottom keeps showing up in a different language)

Hi

Use currentselection to get… current selection, then CellAddress.column. It is however prudent to check that the selection is a cell. To do this, uncomment the lines in the code below:

dim oCell as object
oCell = thiscomponent.currentselection

'if oCell.supportsService("com.sun.star.sheet.SheetCell") then'
	msgbox oCell.CellAddress.column
'else'
'	msgbox "current selection is not a cell"	'
'end if '

Regards

Please also note that cell and range addresses start numbering with 0.

Thank you very much for this. It works just as I needed it to.

I was able to make my own function with your code, but I never would have been able to do it from scratch myself. For instance, oCell.supportsService(“com.sun.star.sheet.SheetCell”) would have never occured to me and I don’t think I even stumbled across any reference to such in my search yesterday.

If there is a good reference listing and explaining the structure of properties of these objects, I would sure love to know about it.

Thanks, again… and yes, Lupp, I was aware of that.

Thank you for feedback.

My main source of documentation is IDL Reference. I also recommand Andrew Pitonyak and use of MRI extension as described here.