[Solved] Read all ods-Files from a directory & analyse cells
Posted: Tue Jul 11, 2017 11:43 am
Hello,
I want to read all ods-files from a directory and want to analyse some cells in the files. My problem ist reading the cells of the opened ods-files to collect the data in the actuell sheet.
Have someone an easy solution ?
thanks for helping me!
I want to read all ods-files from a directory and want to analyse some cells in the files. My problem ist reading the cells of the opened ods-files to collect the data in the actuell sheet.
Have someone an easy solution ?
Code: Select all
Sub readfiles()
strPath = "D:\Snippings\test\"
strExt = "*.ods"
Dim strFile As String
If strPath = "" Then
Exit Sub
Else
strFile = Dir(strPath & strExt)
Do While Len(strFile) > 0
Filename=strPath & strFile
sURL = ConvertToURL(Filename)
oDoc = StarDesktop.loadComponentFromURL(sURL, "_blank", 0, Array())
rechdoc = thisComponent '??????want to read a cell in the opened file not my current sheet
rechsheet = rechdoc.sheets(0)
rechdat = rechsheet.getCellRangeByName("$F$16")
' write data to cells in my current sheet
oDoc.close(true)
strFile = Dir() ' next file
Loop
End If
End Sub