Copies the specified Sheet from multiple Documents in a specific folder to an existing Document. The code must be in My Macros.

' The code must be in My Macros 
' Copies the specified Sheet from multiple Documents in a specific folder to an existing Document..
Sub DiffdocOnedocShCopy
Dim fromDoc As Object
Dim toDoc As Object
Dim strResult As String

Url = ConvertToUrl("C:/Gyoumu/Kaikake/test.ods")
toDoc = StarDesktop.loadComponentFromURL(Url, "_blank", 0, Array())
toDocName = toDoc.Title
Mid(toDocName, LEN(toDocName) -3, 4,"") ' <= Except extension Ver5.2 necessary, Ver5.3 Unnecessary

strResult = Dir("C:/sample/*.ods",0)
Do While strResult <> ""
strUrl = ConvertToUrl("C:/sample/" & strResult)
fromDoc = StarDesktop.loadComponentFromURL(strUrl, "_blank", 0, Array())
sheetName = "test"
If fromDoc.Sheets.hasByName(sheetName) Then
fromDoc.CurrentController.setActiveSheet( fromDoc.Sheets.getByName(sheetName))
diffdocOnedocCp(fromDoc, toDocName)
'diffdocOnedocCp(fromDoc, toDocName) ' <= Twice
End If
fromDoc.close(True)
strResult = Dir
Loop
'toDoc.close(True)
End Sub

Sub diffdocOnedocCp(fromDoc, toDocName)
Dim frame as Object
Dim dispatcher as Object
Dim args1(2) as new com.sun.star.beans.PropertyValue

frame = fromDoc.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
args1(0).Name = "DocName"
args1(0).Value = toDocName
args1(1).Name = "Index"
args1(1).Value = 32767 ' <= When moving to the back
args1(2).Name = "Copy"
args1(2).Value = true ' <= Move is false, Copy is true
dispatcher.executeDispatch(frame, ".uno:Move", "", 0, args1())
End Sub