OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

multi-selection

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
emilie
General User
General User


Joined: 26 Jun 2004
Posts: 5
Location: paris

PostPosted: Sun Jun 27, 2004 11:34 pm    Post subject: multi-selection Reply with quote

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
View user's profile Send private message
davidh182
OOo Advocate
OOo Advocate


Joined: 01 Apr 2004
Posts: 413

PostPosted: Mon Jun 28, 2004 3:19 am    Post subject: Reply with quote

.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
View user's profile Send private message Send e-mail
emilie
General User
General User


Joined: 26 Jun 2004
Posts: 5
Location: paris

PostPosted: Mon Jun 28, 2004 5:19 am    Post subject: thank you davidh182 Reply with quote

thank for your help
it was very useful Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group