Ask Your Question
0

Calc: macro to copy, paste, then clear clipboard

asked 2015-10-19 21:14:14 +0100

Wolbee gravatar image

updated 2016-03-16 22:02:14 +0100

Alex Kemp gravatar image

(Using LO Calc 5.0.2.2 64-bit on Windows 10, both Eng-UK)

I've got a macro that I recorded to copy and paste a range of cells, but when it finishes, I'm left with the dashed lines around the data that was copied.

I'm basically looking for a LO equivalent to VBA's "Application.CutCopyMode = False" to clear the copied data.

Here's my macro (apologies for nonsense attributed to recorded macro):

sub DailyXP
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$F$2:$F$30"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())

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

rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$C$2:$C$30"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())

rem ----------------------------------------------------------------------
dim args4(5) as new com.sun.star.beans.PropertyValue
args4(0).Name = "Flags"
args4(0).Value = "SVDT"
args4(1).Name = "FormulaCommand"
args4(1).Value = 0
args4(2).Name = "SkipEmptyCells"
args4(2).Value = false
args4(3).Name = "Transpose"
args4(3).Value = false
args4(4).Name = "AsLink"
args4(4).Value = false
args4(5).Name = "MoveMode"
args4(5).Value = 4

dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args4())

rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:TerminateInplaceActivation", "", 0, Array())

rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:Cancel", "", 0, Array())


end sub
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2018-07-23 10:56:07 +0100

neptunus gravatar image

updated 2018-07-24 15:07:04 +0100

For me, I found a working solution for this problem, although it's not an elegant one ;)

Maybe you must be careful for the effects in your spreadsheet and test it first!

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

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

end with: dispatcher.executeDispatch(document, ".uno:Cancel", "", 0, Array())

And of course; remove de REM's before these commands.

In the meantime, I discovered that it only works by use of the push button, which seems very strange to me. May be it has something to do with the settings of the form controls.

Apologies for my poor attempts, I'm just a beginner. But I like to contribute my findings.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-10-19 21:14:14 +0100

Seen: 1,503 times

Last updated: Jul 24