I started working on a calc macro to modify cells based on user's selection. I wanted to see if it would handle a single selection as well as multiple selections. When I select more than one range at a time, ThisComponent.getCurrentSelection().getCount() returns the number I'd expect, but if there is only one range or one cell selected, I get: BASIC runtime error. Property or Method not found.
I'm puzzled - I must be using this method incorrectly, but I haven't found the "correct" way - can anyone point me to something that would set me straight?
Also, is there an "expanded class document" somewhere that would tell me all the properties and methods of an object, taking into consideration any inheritance? For example, I know that getCurrentSelection() returns a selection object - how can I get a list of all the methods and properties that are now available to me?
getCount method comes & goes?
getCount method comes & goes?
OOo 3.3.X on Ms Windows XP
Re: getCount method comes & goes?
We are talking StarBasic? The following function should help. It returns a collection of ranges or Null if some object is selected rather than cells.
A single cell supports service c.s.s.sheet.SheetCell additionally.
Don't try to write macros without having Xray installed: http://ooomacros.org/dev.php#101416
Code: Select all
function getSheetCellRanges(obj)
if obj.supportsService("com.sun.star.sheet.SheetCellRange") then
' the intersection with it's own address returns a collection with this range alone
' a single cell supports SheetCellRange as well
getRangesSelection = obj.queryIntersection(obj.getRangeAddress())
elif obj.supportsService("com.sun.star.sheet.SheetCellRanges") then
getRangesSelection = obj
else ' some kind of shape is selected
getRangesSelection = Null
endif
end function
Don't try to write macros without having Xray installed: http://ooomacros.org/dev.php#101416
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice