Multible files in miltible sheets

Hi

I want to load two files into the same clac file, with two sheets

    sUrl = convertToUrl("C:\Users\File1.txt")
    sSheetName = "File1"
    
      Dim FileProperties(1) As New com.sun.star.beans.PropertyValue
        FileProperties(0).Name = "FilterName"
        FileProperties(0).Value ="Text - txt - csv (StarCalc)"
        FileProperties(1).Name = "FilterOptions"
        'FileProperties(1).Value = "FIX,,0,1,0/2/10/36/19/4"
    	FileProperties(1).Value = "9,34,ANSI,1,1/2/2/2/3/1/4/1"
        oCSV = StarDesktop.loadComponentFromURL( sUrl, "_blank", 0, FileProperties())
       
    oSourceSheet = oCSV.Sheets( 0 )
    osourcesheet.name=sSheetName

 sUrl = convertToUrl("C:\Users\File2.txt")
sSheetName = "File2"

  Dim FileProperties(1) As New com.sun.star.beans.PropertyValue
    FileProperties(0).Name = "FilterName"
    FileProperties(0).Value ="Text - txt - csv (StarCalc)"
    FileProperties(1).Name = "FilterOptions"
    'FileProperties(1).Value = "FIX,,0,1,0/2/10/36/19/4"
	FileProperties(1).Value = "9,34,ANSI,1,1/2/2/2/3/1/4/1"
    oCSV = StarDesktop.loadComponentFromURL( sUrl, "_blank", 0, FileProperties())
       
    oSourceSheet = oCSV.Sheets( 0 )
    osourcesheet.name=sSheetName

But it open two calc files insted of one calc file with two sheets

Pleace help

OK, Cal2, try this

Sub Main
	sFilterName = "Text - txt - csv (StarCalc)"
	sFilterOptions = "9,34,ANSI,1,1/2/2/2/3/1/4/1"
	GlobalScope.BasicLibraries.LoadLibrary("Tools")	
	oDoc = CreateNewDocument("scalc")
	oSheets = oDoc.getSheets()
	AddNewSheet(oSheets, "C:\Users\File2.txt", "File2", sFilterName, sFilterOptions)
	AddNewSheet(oSheets, "C:\Users\File1.txt", "File1", sFilterName, sFilterOptions)
End Sub 

Sub createNewSpreadsheet(oSheets as Object, sFileName As String, sSheetName As String, _
					sFilterName As String, sFilterOptions As String)
oSheets.insertNewByName(sSheetName, 0)
oSheet = oSheets.getByIndex(0)
oSheet.link(convertToUrl(sFileName), _
			GetFileNameWithoutExtension(sFileName, GetPathSeparator()), _
			sFilterName, sFilterOptions,com.sun.star.sheet.SheetLinkMode.VALUE)
oSheet.setLinkMode(com.sun.star.sheet.SheetLinkMode.NONE)
End Sub

Of course, this will work if: you correctly defined the filter parameters and the files are exists in the place where you specified