Copy all worksheets in source file “/tmp/sample.ods” into target file “/tmp/new.ods”:
Sub Main
Dim FileProperties(0) As New com.sun.star.beans.PropertyValue
FileProperties(0).Name = "Hidden"
FileProperties(0).Value = true
Url_new = "private:factory/scalc"
set Target = StarDesktop.loadComponentFromURL(Url_new, "_blank", 0,FileProperties)
Path_source = "/tmp/sample.ods"
Url_source = ConvertToUrl(Path_source)
Source = StarDesktop.loadComponentFromURL(Url_source, "_blank", 0, FileProperties)
position = 0
For Each sheet In Source.Sheets
Target.sheets.importSheet(Source, sheet.Name, position)
position = position +1
Next
Path_target = "/tmp/new.ods"
Url_target = ConvertToUrl(Path_target)
Target.storeAsURL(Url_target,FileProperties)
End Sub
Help someone make it more shorter.