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

Call current cell from a function.

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


Joined: 01 Feb 2003
Posts: 432
Location: Mexico

PostPosted: Tue Oct 09, 2007 8:14 pm    Post subject: Call current cell from a function. Reply with quote

Hi I got a script that replicates the current page to the rest of the page. After that I have a function that will do for a single cell. However I have to specify the cell through the Col/Row coordinates.

However I want to get a line that instead of punching arrays I can get the current cell as well as the current string on the cell.

This will make it easier from an user as I will only need to position myself on a cell and the rest will replicate.

My script at the moment looks like this:

Code:
Sub CellLabeler
  Dim oCell as Variant
  Dim firstDoc as Variant
  Dim oSheet as Variant
  Dim someText as Variant
  Dim x
  someText = "Tenet"
  column = 19
  row = 3
 
  firstDoc = ThisComponent
  for x = 0 to 34
  y= x
  oSheet= firstDoc.getSheets().getByIndex(y)
  oSheet.GetCellbyPosition( row -1 , column -1 ).SetString(someText) 
  Next x
End Sub


I want to replace the GetCellByPosition() to a current cell where the string can copy to the rest of the sheets.
_________________
Alexandro Colorado
PPMC Apache OpenOffice
http://es.openoffice.org
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 9183
Location: Lexinton, Kentucky, USA

PostPosted: Wed Oct 10, 2007 9:56 am    Post subject: Reply with quote

I think I know what you want. This macro will copy the text from the currently active cell and put in the same position in all sheets.
Code:
Sub CellLabeler
  Dim oCell,oSheets,oSheet,oDoc,cellText,column,row,s
  oDoc = ThisComponent
  oCell = oDoc.getCurrentSelection
  column = oCell.CellAddress.Column
  row = oCell.CellAddress.Row
  cellText = oCell.getString
  oSheets = oDoc.getSheets
  For s = 0 to oSheets.Count - 1
   oSheet= oDoc.getSheets().getByIndex(s)
   oSheet.GetCellbyPosition(column,row).SetString(cellText)
  Next s
End Sub
Back to top
View user's profile Send private message
JZA
OOo Advocate
OOo Advocate


Joined: 01 Feb 2003
Posts: 432
Location: Mexico

PostPosted: Wed Oct 10, 2007 10:58 am    Post subject: Reply with quote

Works like a Charm... Smile
_________________
Alexandro Colorado
PPMC Apache OpenOffice
http://es.openoffice.org
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
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