Public Sub OpenExlFile(ExcelPath As String)
Attempt1:
On Error GoTo Fail1
' Assume we're running Microsoft Excel
' Inicio: Rotina original
Workbooks.OpenText FileName:=ExcelPath, _
Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Local:=True
Workbooks.Application.Columns.AutoFit
' Fim: Rotina Original
Exit Sub
Fail1:
Resume Attempt2
Attempt2:
On Error GoTo Fail2
' Perhaps we're running LibreOffice or OpenOffice
StarOpenTsvFile (ExcelPath)
Fail2:
Exit Sub
End Sub
Public Sub StarOpenTsvFile(tsvPath As String)
Dim starDesktop As Object
Dim url As String
Dim doc As Object
Dim parms(1) As New com.sun.star.beans.PropertyValue
parms(0).Name = "FilterName"
parms(0).Value = "Text - txt - csv (StarCalc)" ' Name is incorrect, but required
parms(1).Name = "FilterOptions"
parms(1).Value = "9,,65535,1" ' Tab seps, no string delim, UTF-16 charset, begin at line 1
starDesktop = createUnoService("com.sun.star.frame.Desktop")
url = ConvertToUrl(tsvPath)
doc = starDesktop.loadComponentFromURL(url, "_blank", 0, parms)
End Sub
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
3 | |
3 | |
3 | |
3 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 |