I would like my macro to use the information that I put on my clipboard. The problem is strange because of what does actually happen. Here I will list the steps of the macro and explain how they are handled:
- Paste the text on the clipboard into the cells of the sheet. (This works great but it also produces the “Text Import” dialog.)
- Copy the cells which already have formulas that find the data I need. (This works, apparently, because see the next step…)
- Paste the calculated values into the cells where I need to use them. (This works great, which is weird because the macro does it again for some other values and it seems to have no effect for this second area.)
- Perform steps 2 and 3 again with a different area of cells. (This never happens.)
No errors are produced. The code is below…
sub TransferKraken
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 arg1(0) as new com.sun.star.beans.PropertyValue
arg1(0).Name = "Nr"
arg1(0).Value = 2
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, arg1())
rem ----------------------------------------------------------------------
dim args8(0) as new com.sun.star.beans.PropertyValue
args8(0).Name = "ToPoint"
args8(0).Value = "$S$3"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args8())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
rem ----------------------------------------------------------------------
args8(0).Value = "$M$23"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args8())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
args8(0).Value = "$K$7"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args8())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:PasteOnlyValue", "", 0, Array())
rem ----------------------------------------------------------------------
dim args5(0) as new com.sun.star.beans.PropertyValue
args5(0).Name = "ToPoint"
args5(0).Value = "$N$23:$N$30"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args5())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
args8(0).Value = "$B$9:$B$16"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args8())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:PasteOnlyValue", "", 0, Array())
rem ----------------------------------------------------------------------
args8(0).Value = "$M$24:$M$31"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args8())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
args8(0).Value = "$E$10:$E$17"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args8())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:PasteOnlyValue", "", 0, Array())
end sub