https://bugs.documentfoundation.org/show_bug.cgi?id=156967
Bug ID: 156967
Summary: CALC: Basic: CSV import macro crashes Calc 7.6.0.3
(worked fine in 7.5)
Product: LibreOffice
Version: 7.6.0.3 release
Hardware: x86-64 (AMD64)
OS: Windows (All)
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: BASIC
Assignee: [email protected]
Reporter: [email protected]
Created attachment 189199
--> https://bugs.documentfoundation.org/attachment.cgi?id=189199&action=edit
Example CSV-file used (personal details edited)
I migrated from 7.5 to 7.6.0.3 this weekend on my Windows 10 laptop (details
below). Running into trouble with a few of my macro's in Calc. I use them to
process CSV-files which I download from my bank. The macro moves and opens the
file and processes the content. They worked flawless in LO 7.5.
In version 7.6, those macro's consistently crash early in the process. I have
narrowed it down to 'roughly somewhere in the code below'.
The error I get is the following:
BASIC runtime error.
An exception occurred
Type: com.sun.star.uno.RuntimeException
Message: [mscx_uno bridge error] UNO type of C++ exception unknown:
"std.system_error", RTTI-name = ".?AVsystem_error@std@@"!.
Example CSV-file attached. Please have mercy on me, this is my first ever bug
report...
```
Sub ImportFromMyBank()
'Here is some initial code
'Somewhere in the section below the macro and Calc crash.
'Move file to Archive Directory
'DirDownloads and 'DirArchiveMyBank are named fields containing directory names
FromPath =
ThisComponent.NamedRanges.getByName("DirDownloads").getReferredCells.String
ToPath =
ThisComponent.NamedRanges.getByName("DirArchiveMyBank").getReferredCells.String
ImportFileName = Dir(FromPath & "CSV_?_*.csv")
ImportFileFullName = FromPath & ImportFileName
If FileExists(ImportFileFullName) Then
NewFullFileName = ToPath + ImportFileName
Else
MsgBox ("MyBank file does not exist.", MB_OK +
MB_ICONINFORMATION, "GnuCash Converter")
Exit Sub
End If
FileCopy ImportFileFullName, NewFullFileName
Kill ImportFileFullName
'Open requested xMyBank file and copy data
path = ConvertToURL(NewFullFileName)
opt(0).Name = "Hidden"
opt(0).Value = True
opt(1).Name = "FilterName"
opt(1).Value = "Text - txt - csv (StarCalc)"
opt(2).Name = "FilterOptions"
opt(2).Value =
"44,34,0,0,1/2/2/2/3/2/4/1/5/4/6/4/7/1/8/1/9/2/10/2/11/2/12/2/13/2/14/2/15/2/16/2/17/2/18/2/19/2/20/2/21/2/22/2/23/2/24/2/25/2/26/2,1,false,false,false,false,false"
cell = ThisComponent.Sheets.getByName("Data").getCellRangeByName("A1")
'The "Data" worksheet exists, it is created in the Initial Code
target = next_cell(cell)
csv = StarDesktop.loadComponentFromURL(path, "_blank", 0, opt())
sheet = csv.Sheets.getByIndex(0)
cell = sheet.getCellRangeByName("A1")
cursor = sheet.createCursorByRange(cell)
cursor.collapseToCurrentRegion()
ra = cursor.RangeAddress
data = sheet.getCellRangeByPosition(ra.StartColumn, ra.StartRow,
ra.EndColumn, ra.EndRow).DataArray
copy_to(target, data)
csv.close(True)
'Here follows the rest of the macro processing the file
End Sub
'----------- GENERIC FUNCTIONS -------------------
Function copy_to(cell, data)
ra = cell.RangeAddress
s = cell.SpreadSheet
cols = ra.EndColumn + UBound(data(0))
rows = ra.EndRow + Ubound(data)
range = s.getCellRangeByPosition(ra.StartColumn, ra.StartRow, cols,
rows)
range.DataArray = data
End Function
Function next_cell(cell)
cursor = cell.SpreadSheet.createCursorByRange(cell)
cursor.gotoEnd()
row = cursor.RangeAddress.EndRow
next_cell = cell.SpreadSheet.getCellByPosition(0, row + 1)
End Function
```
-----
Version: 7.6.0.3 (X86_64) / LibreOffice Community
Build ID: 69edd8b8ebc41d00b4de3915dc82f8f0fc3b6265
CPU threads: 12; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: nl-NL (nl_NL); UI: en-US
Calc: threaded
--
You are receiving this mail because:
You are the assignee for the bug.