| View previous topic :: View next topic |
| Author |
Message |
JZA OOo Advocate


Joined: 01 Feb 2003 Posts: 432 Location: Mexico
|
Posted: Tue Oct 09, 2007 8:14 pm Post subject: Call current cell from a function. |
|
|
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 |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8979 Location: Lexinton, Kentucky, USA
|
Posted: Wed Oct 10, 2007 9:56 am Post subject: |
|
|
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 |
|
 |
JZA OOo Advocate


Joined: 01 Feb 2003 Posts: 432 Location: Mexico
|
Posted: Wed Oct 10, 2007 10:58 am Post subject: |
|
|
Works like a Charm...  _________________ Alexandro Colorado
PPMC Apache OpenOffice
http://es.openoffice.org |
|
| Back to top |
|
 |
|