If I select A1:A2 AND A4:A5 AND A7:A8 (3 non-contiguous ranges)
and then run macro containing: msgbox ThisComponent.getCurrentSelection().getRangeAddress().Count
I get: 3
Great!
If I select A1:A2 AND A4:A5 (2 non-contiguous ranges)
and then run the same macro, I get: 2
Great!
If I select A1:A2 (a single range)
and then run the same macro again: I get: "Property or method not found: Count"
What! Why not 1???
I can see in Xray that the Count property is not exposed in the single range case, but what is the alternative to differentiate the single range case from the multiple, non-contiguous cases.
Please help me figure out how to know if non-contiguous ranges have been selected. I am getting cross-eyed reading the docs and Xray popups and I can't find the key...Thanks...
[Solved] Identifying Multiple Selected Ranges in Calc
[Solved] Identifying Multiple Selected Ranges in Calc
Last edited by Hagar Delest on Sun Sep 02, 2018 11:50 am, edited 1 time in total.
Reason: tagged solved
Reason: tagged solved
OpenOffice 4.1.5 on openSuSE 42.3
Re: Identifying Multiple Selected Ranges in Calc
Please post the full code of your macro (use
Code: Select all
tags).
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: Identifying Multiple Selected Ranges in Calc
Here it is:
Function say()
msgbox ThisComponent.getCurrentSelection().getRangeAddress().Count
End Function
Any help would be appreciated...
Function say()
msgbox ThisComponent.getCurrentSelection().getRangeAddress().Count
End Function
Any help would be appreciated...
OpenOffice 4.1.5 on openSuSE 42.3
Re: Identifying Multiple Selected Ranges in Calc
Code: Select all
oSel = ThisComponent.getCurrentSelection()
If oSel.supportsService("com.sun.star.sheet.SheetCellRanges") Then
print "multi range selection"
End If
If oSel.supportsService("com.sun.star.sheet.SheetCellRange") Then
print "single range selection"
End If
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Identifying Multiple Selected Ranges in Calc
Thank you, that did it for me. I really appreciate the guidance...
OpenOffice 4.1.5 on openSuSE 42.3