I am trying to work with ranges in Calc. However, I cannot figure out how to instantiate a non-contiguous cell range from its address string. The code below (result of AllRanges.AbsoluteName) may for example show "$Sheet1.$C$3:$C$5;$Sheet1.$E$3:$E$4" if my selection consists of two separate ranges.

1) I can't figure out how to instantiate a range from the string "$Sheet1.$C$3:$C$5;$Sheet1.$E$3:$E$4". getCellRangeByName won't do it and neither will insertByName("", "$Sheet1....").

2) Can I easily get the total cell count of my AllRanges object ? AllRanges.Cells.Count seemed intuitive but does not exist.

Cheers
-- Jan Holst Jensen
__________________

Sub Main
 ThisDoc = ThisComponent
 ThisSheet = ThisDoc.CurrentController.ActiveSheet

 SelRange = ThisComponent.getCurrentSelection
' This can be enumerated too - great: SelRange = ThisSheet.getCellRangeByName("A3:A6")

AllRanges = ThisComponent.createInstance("com.sun.star.sheet.SheetCellRanges")
 AllRanges.insertByName("", SelRange)

 c = AllRanges.AbsoluteName
 MsgBox c

 AllCells = AllRanges.Cells.createEnumeration
 While AllCells.hasMoreElements
   Content = AllCells.nextElement.String
   MsgBox Content
 Wend
End Sub


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to