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

Macro to copy text from a text box to the clipboard

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


Joined: 08 Mar 2012
Posts: 9

PostPosted: Thu Jun 14, 2012 4:13 am    Post subject: Macro to copy text from a text box to the clipboard Reply with quote

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
View user's profile Send private message Send e-mail
patel
Power User
Power User


Joined: 14 Apr 2012
Posts: 54
Location: Italy

PostPosted: Thu Jun 14, 2012 10:12 am    Post subject: Reply with quote

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
View user's profile Send private message
ultine
General User
General User


Joined: 08 Mar 2012
Posts: 9

PostPosted: Thu Jun 14, 2012 2:38 pm    Post subject: Reply with quote

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
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