| View previous topic :: View next topic |
| Author |
Message |
emilie General User

Joined: 26 Jun 2004 Posts: 5 Location: paris
|
Posted: Sun Jun 27, 2004 11:34 pm Post subject: multi-selection |
|
|
i wish to obtain the data of zone selected by the user. This functions work very well when I am on only one page. But that does not work, when I have mutiple pages of selected.
I wish to mad a same process on severals sheets selected. but only on the zone selected on the first sheet.
oSelRange = oCurr.getRangeAddress --- propertie or method not find
Can you help me ?
Sub CancellaRigheVuote
Dim iStartCol As Integer
Dim iStartRow As Integer
Dim iEndCol As Integer
Dim iEndRow As Integer
Dim oDoc As Object
Dim oSelection As Object
Dim oSheet As Object
oDoc = ThisComponent
If Not oDoc.SupportsService("com.sun.star.sheet.SpreadsheetDocument") Then
Msgbox "Bad document"
Exit Sub
End If
oSelection = oDoc.currentSelection
If oSelection.supportsService("com.sun.star.sheet.SheetCellRanges") Then
Msgbox "Multiple selection ERROR"
Exit Sub
End If
oSheet = oSelection.Spreadsheet
With oSelection.RangeAddress
iStartCol = .StartColumn
iStartRow =.StartRow
iEndCol = .EndColumn
iEndRow = .EndRow
End With
Print iStartCol,iStartRow,iEndCol,iEndRow
End Sub |
|
| Back to top |
|
 |
davidh182 OOo Advocate

Joined: 01 Apr 2004 Posts: 413
|
Posted: Mon Jun 28, 2004 3:19 am Post subject: |
|
|
.getRangeAddresses is an array consisting of all the selected blocks on the current sheet * all the selected pages.
Would help if it were an array of size one in the basic case - but you need to consider the single & multiple cases separately.
| Code: |
Sub CancellaRigheVuote
Dim iStartCol As Integer
Dim iStartRow As Integer
Dim iEndCol As Integer
Dim iEndRow As Integer
Dim oDoc As Object
Dim oSelection As Object
Dim oSheet As Object
oDoc = ThisComponent
If Not oDoc.SupportsService("com.sun.star.sheet.SpreadsheetDocument") Then
Msgbox "Bad document"
Exit Sub
End If
oSelection = oDoc.currentSelection
If oSelection.supportsService("com.sun.star.sheet.SheetCellRanges") Then
rs=oSelection.RangeAddresses
r=rs(0)
else
r=oSelection.RangeAddress
end if
printrange(r)
dim newsheet as boolean
If oSelection.supportsService("com.sun.star.sheet.SheetCellRanges") Then
for i=LBound(rs)+1 to UBound(rs)
newsheet=true
for j=LBound(rs) to i-1
if rs(i).sheet=rs(j).sheet then newsheet=false
next j
if newsheet then printrange(rs(i))
next i
end if
end sub
sub printrange(r)
With r
isheet = .sheet
iStartCol = .StartColumn
iStartRow =.StartRow
iEndCol = .EndColumn
iEndRow = .EndRow
End With
Print isheet,iStartCol,iStartRow,iEndCol,iEndRow
End Sub |
|
|
| Back to top |
|
 |
emilie General User

Joined: 26 Jun 2004 Posts: 5 Location: paris
|
Posted: Mon Jun 28, 2004 5:19 am Post subject: thank you davidh182 |
|
|
thank for your help
it was very useful  |
|
| Back to top |
|
 |
|