Bug 128065 - BASIC Runtime Error on start LOCalc
Summary: BASIC Runtime Error on start LOCalc
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
5.4.7.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: haveBacktrace
Depends on:
Blocks: Macro-StarBasic
  Show dependency treegraph
 
Reported: 2019-10-10 06:39 UTC by p_consti
Modified: 2022-09-20 18:19 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
File with the macro (14.78 KB, application/vnd.oasis.opendocument.spreadsheet)
2019-10-10 09:00 UTC, p_consti
Details
bt with debug symbols (20.83 KB, text/plain)
2019-10-10 18:48 UTC, Julien Nabet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description p_consti 2019-10-10 06:39:47 UTC
Description:
Since I updated to the new version of LibreOffice (6.3.1.2, buildID: 1:6.3.1~rc2-0ubuntu0.18.04.1~lo1) every time I open my spreadsheet with macros I get a "BASIC Runtime Error - Object Variable Not Defined". This only happens when opening the sheet, when I execute the function (not a sub) manually, it works.

In my function I operate a lot on cells, my guess is that in the new version, the sheets and cells are not ready yet.
Worked before in version 6.0.something

I tested it with "normal" functions that don't rely on the ThisComponent, those work fine.

FILEOPEN

Steps to Reproduce:
1. Open a file with a macro that uses ThisComponent
2. Enable Macros

Actual Results:
BASIC Runtime Error
Object Variable Not Set

Expected Results:
Execute the function without errors


Reproducible: Always


User Profile Reset: No



Additional Info:
Comment 1 Julien Nabet 2019-10-10 08:19:17 UTC
Would it be possible you attach the file so we can try to reproduce this?
Have a look at https://wiki.documentfoundation.org/QA/Bugzilla/Sanitizing_Files_Before_Submission first.
Comment 2 p_consti 2019-10-10 09:00:32 UTC
Created attachment 154892 [details]
File with the macro

Here's the file.

Note that the macro takes in two strings to access cells on a different sheet, I have only included the function-call and the second sheet.
Return is in German.
Comment 3 Oliver Brinzing 2019-10-10 17:10:39 UTC
i can even reproduce the problem with attached file with:

Version: 5.4.7.2 (x64)
Build-ID: c838ef25c16710f8838b1faec480ebba495259d0
CPU-Threads: 4; BS: Windows 6.19; UI-Render: Standard; 
Gebietsschema: de-DE (de_DE); Calc: single

but not with:
LO 4.4.7.2
AOO 4.1.5

i think this issue could be a duplicate of:

Bug 123005 - FILEOPEN: Error on creating getCurrentController().getActiveSheet() for basic script from location=document

cause "Document.CurrentController" reports is Null

'Get Sheet object
If Not IsMissing(startingSheetName) And 
       Document.Sheets.hasByName(startingSheetName) Then
 
   msgbox isnull(Document.CurrentController)
   If startingSheetName = Document.CurrentController.ActiveSheet.Name Then
Comment 4 Julien Nabet 2019-10-10 18:48:12 UTC
Created attachment 154908 [details]
bt with debug symbols

On pc Debian x86-64 with master sources updated today, I got an error message too.
I attached a bt corresponding to the moment I get the error.
Comment 5 QA Administrators 2022-09-20 03:33:42 UTC Comment hidden (obsolete)
Comment 6 Oliver Brinzing 2022-09-20 09:41:36 UTC
repro with:

Version: 7.4.1.2 (x64) / LibreOffice Community
Build ID: 3c58a8f3a960df8bc8fd77b461821e42c061c5f0
CPU threads: 4; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: de-DE
Calc: default
Comment 7 Julien Nabet 2022-09-20 18:19:00 UTC
I gave a new try with master sources updated today and could reproduce this.

After having added some debug traces, I found that the pb was in last line of this block:
Function setupKOSheet(startingSheetName AS String, startingCell as String, Optional numParticipants As Integer, _
        Optional vertSpacing As Integer, Optional horSpacing As Integer, Optional nameWidth As Integer, Optional redColor, Optional blueColor)
    
    Dim Document As Object
    Document = ThisComponent
    'Get Sheet object
    If Not IsMissing(startingSheetName) And Document.Sheets.hasByName(startingSheetName) Then
       If startingSheetName = Document.CurrentController.ActiveSheet.Name Then

Indeed "Document" seems not exist at this moment. (it would confirm the initial description)

Now if I go to the first sheet "Befehle" in A6 and do a recalculate, it works.
(this sheet contains =SETUPKOSHEET("Beispiel";"C2";16))
I wanted to know how the macro was launched at the start, so searched in Tools/Customize/Events and found nothing. It's after a while I saw it was in a formula.

Mike/Andreas: thought you might be interested in this one.