| View previous topic :: View next topic |
| Author |
Message |
berndhe Newbie

Joined: 04 Oct 2006 Posts: 1
|
Posted: Wed Oct 04, 2006 12:07 am Post subject: Import CSV-File into a Calc-Document using OpenOffice 2.0.3 |
|
|
Hello,
How can I import a CSV-File via Macro and copy it into a Calc-Document.
The CSV-File is seperated by ;
I already had an working function under OpenOffice 1. But under OpenOffice it doesn't work.
Please help
Bernd |
|
| Back to top |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
dine General User

Joined: 28 Aug 2006 Posts: 8 Location: Germany
|
Posted: Thu Oct 05, 2006 11:05 pm Post subject: Re: Import CSV-File into a Calc-Document using OpenOffice 2. |
|
|
| berndhe wrote: | Hello,
How can I import a CSV-File via Macro and copy it into a Calc-Document.
The CSV-File is seperated by ;
I already had an working function under OpenOffice 1. But under OpenOffice it doesn't work.
Please help
Bernd |
As far as i see you've got the same problem that i had when i was switching from OO1 to OO2.
i use the function below for importing csv-files (don't know where i got this from anymore)
| Code: |
Function OpenCSVFile (sUrl As String) As Object
' Opens CSV-file
' sUrl MUST be in Url-format (for example: "file:///c:/ddd.sxc")
' ( --> use / not \ )
Dim fileProperties(1) As New com.sun.star.beans.PropertyValue
fileProperties(0).Name = "FilterName"
fileProperties(0).Value = "scalc: Text - txt - csv (StarCalc)"
fileProperties(1).Name = "FilterFlags"
fileProperties(1).Value = "59/9,34,IBMPC_850,1,1/1/1/1/1/1/1/1"
'59/9 --> columns are devided by ";" and tab
'34 --> text delimiter --> double qoutes (")
' IBMPC_850 --> charset (is a constant with the value 4)
' 0 is system charset
OpenCSVFile = StarDesktop.loadComponentFromURL(sUrl,"_blank", 0,fileProperties())
End Function
|
i used this function in OO1 as well but for OO2 i had to change something in the fileproperties...
you can now import the csv by using
| Code: |
oDocCSV = OpenCSVFile([path as URL!])
|
|
|
| Back to top |
|
 |
|