EDIT: I posted a working code in the answers, but not allowed to select it due to age of account or something.
I have 300 lines of data here that need 2 rows inserted after each line and the line duplicated to those rows.
I created a macro to add those 2 lines and have been manually copy pasting… but it takes forever.
How can I macro the copy paste?
Copy r1
Paste r2,3
Copy r4
Paste r5,6
copy r7
Paste r8,9
go to I=50 or end document… I am happy to change the I number to make things simpler for me to understand and write.
This is my current macro, BUT I am happy to use 2 separate macros to accomplish this.
sub Insert_rows_skipping
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 = "By2"
args2(0).Value = 2
dim args3(1) as new com.sun.star.beans.PropertyValue
args3(0).Name = "By"
args3(0).Value = 1
For i = 1 To 124 ' This should be adjusted according to need.
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args3())
dispatcher.executeDispatch(document, ".uno:InsertRowsBefore", "", 0, Array())
args3(0).Value = 2
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args2())
dispatcher.executeDispatch(document, ".uno:InsertRowsBefore", "", 0, Array())
args2(0).Value = 2
Next i
end sub