Determine csv import filter options

Creating Extension - Shared Libraries
Forum rules
For sharing working examples of macros / scripts. These can be in any script language supported by [Basic, Python, Netbean] or as source code files in Java or C# even - but requires the actual source code listing. This forum is not for asking questions about writing your own macros.

Determine csv import filter options

Postby ms777 » Sat Oct 17, 2020 6:51 pm

... this is a repost from the old It helps you if you want to automatize the csv import with non trivial import options

Good luck,

Code: Select all   Expand viewCollapse view
Sub Main
sUrl = ConvertToUrl("C:\Users\Martin\Downloads\test.csv")
sResult = GetFilterOptionsFromCSVImportDialog(sUrl)
msgbox sResult
End Sub

function GetFilterOptionsFromCSVImportDialog(sUrl) as String
GetFilterOptionsFromCSVImportDialog = ""

oSFA = createUNOService ("")
oInputStream = oSFA.openFileRead(sUrl)

Dim aProps(3) as new
aProps(0).Name = "FilterOptions"
aProps(0).Value = ""
aProps(1).Name = "URL"
aProps(1).Value = sUrl
aProps(2).Name = "FilterName"
aProps(2).Value = "Text - txt - csv (StarCalc)"
aProps(3).Name = "InputStream"
aProps(3).Value = oInputStream

'o = createUnoService("")
o = createUnoService("")

if o.execute() = then
  aPropOut = o.getPropertyValues()
  GetFilterOptionsFromCSVImportDialog = aPropOut(0).Value
end function
Posts: 138
Joined: Mon Oct 08, 2007 1:33 am

Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 2 guests