How can I put something INTO the clipboard?
Posted: Thu Jan 01, 2009 11:54 pm
It's quite easy to put something, say text, from the clipboard to the cursorposition. But how can I do the opposite: Put some given text into the clipboard? I tried:
sub main
zwspeichersetzen( "some text" )
texteinfuegen
end sub
sub ZwSpeichersetzen (text$)
rem define variables
dim odocument as object
dim odispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
odocument = ThisComponent.CurrentController.Frame
odispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Text"
args1(0).Value = text$
odispatcher.executeDispatch(odocument, ".uno:Copy", "", 0, args1())
end sub
sub Texteinfuegen
rem define variables
dim odoc as object
dim odis as object
rem ----------------------------------------------------------------------
rem get access to the document
odoc = ThisComponent.CurrentController.Frame
odis = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
odis.executeDispatch(odoc, ".uno:Paste", "", 0, Array())
end sub
The sub Texteinfuegen (=paste) works fine, the other part does not. More exactly: Texteinfuegen pastes the last input of the clipboard, Zwspeichersetzen apparently does nothing at all. Why?
Or more important: How can I change that?
sub main
zwspeichersetzen( "some text" )
texteinfuegen
end sub
sub ZwSpeichersetzen (text$)
rem define variables
dim odocument as object
dim odispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
odocument = ThisComponent.CurrentController.Frame
odispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Text"
args1(0).Value = text$
odispatcher.executeDispatch(odocument, ".uno:Copy", "", 0, args1())
end sub
sub Texteinfuegen
rem define variables
dim odoc as object
dim odis as object
rem ----------------------------------------------------------------------
rem get access to the document
odoc = ThisComponent.CurrentController.Frame
odis = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
odis.executeDispatch(odoc, ".uno:Paste", "", 0, Array())
end sub
The sub Texteinfuegen (=paste) works fine, the other part does not. More exactly: Texteinfuegen pastes the last input of the clipboard, Zwspeichersetzen apparently does nothing at all. Why?
Or more important: How can I change that?