| View previous topic :: View next topic |
| Author |
Message |
ultine General User

Joined: 08 Mar 2012 Posts: 9
|
Posted: Thu Jun 14, 2012 4:13 am Post subject: Macro to copy text from a text box to the clipboard |
|
|
I am just trying to have a user button on spreadsheet that basically does a ctrl+A and then ctrl+C on a text box. I have not been able to find anything for this. A while back I found some stuff about opening a text doc in the background, but it just looked like a really messy workaround that would take a long time (my computer opens OpenOffice documents really slowly).
Any code ideas would be much appreciated.
Using EeePc with Windows XP service pack 3. and ooo 3.3.0
And I'm not very experienced with the Basic syntax used in open office, so some hand holding would be appreciated, as well.
Thanks! _________________ Using OOo 3 on an eee PC 1000h netbook. |
|
| Back to top |
|
 |
patel Power User

Joined: 14 Apr 2012 Posts: 54 Location: Italy
|
Posted: Thu Jun 14, 2012 10:12 am Post subject: |
|
|
Use the clipboard to copy data between two documents.
| Code: | oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
oFrame1 = oDoc1.CurrentController.Frame
' Use the documents controller to select the cells A1:B2.
oSheet = oDoc1.Sheets(0)
rng = oSheet.getCellRangeByName("A1:B2")
oDoc1.CurrentController.Select(rng)
' Use a dispatch to copy to the clipboard.
oDispatcher.executeDispatch(oFrame1, ".uno:Copy", "", 0, Array())
' Upper left corner of where to paste the data.
rng = oDoc2.Sheets(0).getCellRangeByName("A1")
' Place the view cursor there then paste the clipboard.
oDoc2.CurrentController.Select(rng)
oFrame2 = oDoc2.CurrentController.Frame
oDispatcher.executeDispatch(oFrame2, ".uno:Paste", "", 0, Array()) |
_________________ If your problem has been solved please add "[Solved]" to the beginning of your first post title (edit button). |
|
| Back to top |
|
 |
ultine General User

Joined: 08 Mar 2012 Posts: 9
|
Posted: Thu Jun 14, 2012 2:38 pm Post subject: |
|
|
Thanks for the quick reply. If I understood what you wrote you are thinking I am copying from cells, but it is actually a text box. Other thoughts? _________________ Using OOo 3 on an eee PC 1000h netbook. |
|
| Back to top |
|
 |
|