Message de Atte André Jensen  date 2008-04-24 13:56 :
Bernard Marcelly wrote:

Your Copy and Paste instructions work on the same range...
You have to select the origin range, Copy, select the destination range,

Another angle (that also suggests something else is wrong): I recorded a simple macro (select all, 2x paste) in openoffice, and it looks like this:
( ... )

This suggests that selecting a range, and dispatching Paste two times should indeed copy the selected text, something I cannot make my example do.

So another question: Don't I need to tell dispatcher which range I want to copy from? In my code I did:

controller = doc.getCurrentController()
controller.select(rangeCursor)
frame = controller.getFrame()
properties = ()
dispatch_helper.executeDispatch(frame, ".uno:Copy", "", 0, properties)

and assumed that this would set the range. Is that infact the problem with my code? How do control which range the dispatcher uses for it's copy/paste operation?


My answer is the same as previous.
Here is a recorded macro that works :
Start record, selection of A2:B4, Copy, click D7 of the same sheet, Paste, click C15 of the same sheet, Paste, End record.
I have suppressed superfluous comment lines.

dim document   as object
dim dispatcher as object

document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ToPoint"
args2(0).Value = "$A$2:$B$4"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args2())

dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())

dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "ToPoint"
args4(0).Value = "$D$7"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args4())

dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())

dim args6(0) as new com.sun.star.beans.PropertyValue
args6(0).Name = "ToPoint"
args6(0).Value = "$C$15"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args6())

dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())


   Bernard

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to