Ask Your Question
0

How to copy a row to multiple sheets?

asked 2015-06-29 19:31:10 +0200

Cobra gravatar image

updated 2015-08-25 07:03:07 +0200

Alex Kemp gravatar image

Calc Ver.: 4.3.6.2 SK Win7 Home SK

Hello, I need to copy one line to multiple sheets. I recorded this macro, but it is only for 1 sheet.

    REM  *****  BASIC  *****


sub CopyLine
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 = "$A$1:$C$2"

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 = "Nr"
args3(0).Value = 2   =>This line says where to copy, I need to set a range of sheets 2nd-40th.

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

rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "ToPoint"
args4(0).Value = "$A$1"

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

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


end sub

I'm using Basic macro.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2015-06-30 10:51:44 +0200

pierre-yves samyn gravatar image

Hi

As in the interface you can select the target sheets before pasting. For example, to select the third and fourth sheet (numbering starts at zero):

args1(0).Name = "Tables"
args1(0).Value = Array(2,3)

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

After pasting, to unselect and select for example the first sheet :

args1(0).Name = "Tables"
args1(0).Value = Array(0)

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

Regards

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2015-06-29 19:31:10 +0200

Seen: 637 times

Last updated: Jun 30 '15