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

How to get cell Range from selected area

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


Joined: 22 Apr 2008
Posts: 2

PostPosted: Tue Apr 29, 2008 12:03 am    Post subject: How to get cell Range from selected area Reply with quote

Hello

I am developing new Extension for open office Cal(Spreadsheet)
For that I am using Net Beans 5.5 , JDK 6.0 OpenOffice 3.0 Smile

I want to get cell rage of selected area Rolling Eyes

Scenario
If I open a new spreadsheet and select some Cell by using Mouse then I want cell Range Address for selected cells so I can access data from cell

Please tell me how to get cell Range from selected area Question

Thanks
Back to top
View user's profile Send private message
radhika_24
General User
General User


Joined: 10 Nov 2008
Posts: 19

PostPosted: Thu Nov 20, 2008 3:23 am    Post subject: Reply with quote

Please Please can anyone help me!!!
i want to access the cells that have been currently selected by the user and then put the data in the cell adjacent to the selected cells... Rolling Eyes Sad Sad Sad
I m totally lost ... last time i had a got a very prompt response from here Smile
hope to the same soon !!! thanks a ton !!
Radhika
Back to top
View user's profile Send private message Send e-mail
vitcaro
OOo Advocate
OOo Advocate


Joined: 20 Feb 2007
Posts: 256
Location: Italy

PostPosted: Thu Nov 20, 2008 6:53 am    Post subject: Reply with quote

This example is Basic:
Code:

CellRange = oDocument.getCurrentSelection()
RangeAddress = CellRange.getRangeAddress
Back to top
View user's profile Send private message
radhika_24
General User
General User


Joined: 10 Nov 2008
Posts: 19

PostPosted: Thu Nov 20, 2008 11:43 pm    Post subject: Reply with quote

Thanks for that Smile really..!
But When i print the value of RangeAddress - it says Basic Runtime error.
And can you tell me what could be the format of RangeAddress, i assume its in vector form as in 2,3 or something.
Thanks for the help Smile
Radhika
Back to top
View user's profile Send private message Send e-mail
vitcaro
OOo Advocate
OOo Advocate


Joined: 20 Feb 2007
Posts: 256
Location: Italy

PostPosted: Fri Nov 21, 2008 12:48 am    Post subject: Reply with quote

Example of use of CellRangeAddress:
Code:

c1 = RangeAddr.StartColumn
r1 = RangeAddr.StartRow
c2 = RangeAddr.EndColumn
r2 = RangeAddr.EndRow
sh = RangeAddr.Sheet
Back to top
View user's profile Send private message
radhika_24
General User
General User


Joined: 10 Nov 2008
Posts: 19

PostPosted: Mon Nov 24, 2008 4:39 am    Post subject: Reply with quote

hey guys thanks a lot for the help!!!

i have compiled the code together and now if anyone needs to access the cells dynacmically according to the user's selection, can readily use this code Smile

Sub Main
Dim oDocument As Object, oSheet As Object, oCell As Object, bCell As Object
oDocument=ThisComponent
Dim oSelection as Object
Dim oRange as Object
Dim r,c as integer
Dim oRangeAddress as New com.sun.star.table.CellRangeAddress

oDocument = StarDesktop.ActiveFrame.Controller.Model
oSheet = oDocument.CurrentController.getActiveSheet() ' get actual sheet

oSelection = oDocument.CurrentController.getSelection
oRangeAddress = oSelection.getRangeAddress ' get actual range / obtiene el rango actual

r = oRangeAddress.StartRow 'current row / la fila actual
c = oRangeAddress.StartColumn 'current column / la columna actual
oCell=oSheet.getCellByPosition(c,r)
End Sub

Enjoy,
Radhika Smile
Back to top
View user's profile Send private message Send e-mail
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