Usually I would expect the variable to hold all the files in it as a string that needs parsed into the individual files. But alas... this is not true.
- Code: Select all Expand viewCollapse view
Function fImportLocalFile() as String 'DONE
'this function opens a system file open dialog box and allows the
' user to pick a file from thier computer to open into the
' document for processing
'stores the filedialog object
Dim oFileDialog as Object
'stores the returned result of the activation of the dialog box
Dim iAccept as Integer
'stores the returned file name/path from the file dialog box
Dim sPath as String
'stores the set default path for the dialog box
Dim InitPath as String
'stores the types of files allowed in the filedialog
Dim sFilterNames as String
'setup the filters for the types of files to allow in the dialog
sFilterNames = "*.csv; *.txt; *.odt; *.ods; *.xls; *.xlt; *.xlsx"
'create the dialog box as a Windows File Dialog
oFileDialog = CreateUnoService("com.sun.star.ui.dialogs.SystemFilePicker")
'set the filters for the dialog
oFileDialog.AppendFilter("Supported files", sFilterNames)
'set the path as blank
InitPath = ""
'add the default path to the dialog
oFileDialog.setDisplayDirectory(InitPath)
'setup the dialog to allow multiple files to be selected
oFileDialog.setMultiSelectionMode(True)
'set iAccept as the execution of the dialog
iAccept = oFileDialog.Execute()
'execute and test if dialog works
If iAccept = 1 Then
'set sPath as the chosen file from the dialog
sPath = oFileDialog.Files(0)
'set the function as sPath for returning to the previous sub
fImportLocalFile = sPath
'end current if statement
End If
End Function
How can I adjust the above code to get the files bak in an array that I can then loop through and open and read the contents from?
I plan on using a loop to do the reading of the files from the array using Lbound and Ubound in a fancy For-Next loop.
And will the method work with the OOo File Picker as well? I use it to access the an FTP server to pull files from as well.
A post by DannyB has an Object read set to oFileDialog.getFiles() and I tried this as well but the editor called me an idiot.
Here is DannyB's post http://www.oooforum.org/forum/viewtopic.phtml?t=3582

