| View previous topic :: View next topic |
| Author |
Message |
thehl Guest
|
Posted: Wed Apr 14, 2004 7:20 am Post subject: Copying the current cell to another sheet |
|
|
I'm a beginner with OO macros and am looking to write a VERY simple macro to copy some cells from one sheet to another. I want to copy the cell under the cursor in sheet to sheet2, then move the cursor down in sheet1 and copy that to a cell in sheet 2, etc. Pretty simple stuff, but I can't seem to find how to get the active cell in a given sheet. I've searched around a lot and thought someone has to know how to do this. Why are there no examples of this in the docs?
Thanks. |
|
| Back to top |
|
 |
dfrench Moderator

Joined: 03 Mar 2003 Posts: 1605 Location: Wellington, New Zealand
|
Posted: Wed Apr 14, 2004 11:37 am Post subject: |
|
|
This pretty simple stuff is covered in the docs and in posts on these forums ... try the [search] link above. A good place to start is the Programmers tutorial http://api.openoffice.org/basic/man/tutorial/tutorial.pdf and the Programmers Guide http://docs.sun.com/db/doc/817-1826?q=StarOffice+basic. There is a full documentation of the API in the SDK downloadable from api.openoffice.org.
There are many examples in this and the code snippets forum .
While you could step around the viewed sheet by cursor, it is not a good way of coding assignment across sheets... the code below demonstrates the assignment in 2 ways.
| Code: | Sub Main
oDoc=ThisComponent 'reference the document running the macro
oSheet1=oDoc.getSheets().getByName("Sheet1") 'reference individual sheets by name
oSheet2=oDoc.getSheets().getByName("Sheet2")
oSheet2.getCellByPosition(0,0).value=oSheet1.getCellByPosition(0,0).value ' assign value
oSheet2.getCellRangeByName("A2:A3").setDataArray(oSheet1.getCellRangeByName("A2:A3").getDataArray) 'assign content
End Sub |
|
|
| Back to top |
|
 |
|
|
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
|