Bug 77722 - Excel file with VBA goes into an infinite error loop upon load
Summary: Excel file with VBA goes into an infinite error loop upon load
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.2.2.1 release
Hardware: All All
: high major
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-VBA
  Show dependency treegraph
 
Reported: 2014-04-21 09:23 UTC by ssrsh82
Modified: 2025-07-23 16:23 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
Reference Excel file that shows the problem described (1.92 MB, application/vnd.ms-excel)
2014-04-21 09:23 UTC, ssrsh82
Details
Excel file with the issue (3.22 MB, application/vnd.ms-excel)
2018-12-08 10:07 UTC, eisa01
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ssrsh82 2014-04-21 09:23:58 UTC
Created attachment 97678 [details]
Reference Excel file that shows the problem described

Hi,

The attached Excel file is downloaded from http://acesdownload.nic.in/Documents/ACES-EFiling-ST3_Oct-Mar_2013_onwards_V1.1.xls.zip (see http://acesdownload.nic.in/ for similar utilities). When this file is opened using LibreOffice 4.2.2 it continuously displays an error and never closes. We are forced to kill the application via Task manager.

The OS is Windows 7 Professional 64-bit OS. This files opens normally in Microsoft Excel 2010.

We have recently migrated all our systems to Libre Office 4.2.2. Appreciate your addressing the Libre Office Spreadsheet issue that is being reported ASAP. This will ensure our confidence in relying on LibreOffice for our day to day usage.

Thank you,
SS
Comment 1 Jorendc 2014-04-21 10:31:09 UTC
Reproducible, tested using Mac OSX 10.9 with LibreOffice Version: 4.3.0.0.alpha0+
Build ID: 619b4c40da9e85febbb08a3f7cf8aa8d10963fc1
TinderBox: MacOSX-x86@49-TDF, Branch:master, Time: 2014-04-18_00:07:53

Looks like there are some macros in it which cause this behavior?

This is not a blocker for sure (no data loss/crash etc). Following https://wiki.documentfoundation.org/images/0/06/Prioritizing_Bugs_Flowchart.jpg this is major high (unable to open particular documents).

Kind regards,
Joren
Comment 2 Kohei Yoshida 2014-05-07 02:30:02 UTC
This Excel file is heavily armed with tons of VBA code.  Still, not good to start running VBA code before asking "do you want to enable macro" thing.
Comment 3 QA Administrators 2015-06-08 14:42:50 UTC Comment hidden (obsolete)
Comment 4 ssrsh82 2015-06-18 09:37:49 UTC
Hi QA Team,

As per the request from QA Administrators, this issue has been retested with LibreOffice Calc 4.4.3. The problem still exists. There is no change in the behavior, the problem persisted until the program is forcibly terminated in the TaskManager. The test was conducted on a desktop with Windows 7 Professional 64-bit OS.

Thank you,
SS
Comment 5 QA Administrators 2016-09-20 10:26:00 UTC Comment hidden (obsolete)
Comment 6 eisa01 2018-12-08 10:06:26 UTC
Opens fine if I disable macros, so if that was an issue before as alluded to in comment  #2, that is fixed.

If I enable macros I get many Basic errors, which eventually cash the document to crash, Libreoffice itself doesn't crash.

Original link to attachment is dead, and the attached version is corrupted. Will reupload a version I found on Archive.org

Version: 6.3.0.0.alpha0+
Build ID: beae6c7a7f163daad0d4dea63a3d403af2745fd1
CPU threads: 2; OS: Mac OS X 10.13.6; UI render: default; VCL: osx; 
TinderBox: MacOSX-x86_64@49-TDF, Branch:master, Time: 2018-12-06_23:52:29
Locale: en-US (en_US.UTF-8); UI-Language: en-US
Calc: threaded
Comment 7 eisa01 2018-12-08 10:07:37 UTC
Created attachment 147379 [details]
Excel file with the issue
Comment 8 QA Administrators 2019-12-09 03:39:47 UTC Comment hidden (obsolete)
Comment 9 eisa01 2020-02-15 17:38:15 UTC
This is still present.

Basic complains about syntax errors. I'm not able to close the code editor window, if I try, it will just complain about the syntax errors again.

If I go back to the document file window I get into an infinite loop of syntax errors

Version: 7.0.0.0.alpha0+
Build ID: 0cb4f304abf6f8dd6b40eb800788d2fe80581813
CPU threads: 4; OS: Mac OS X 10.14.6; UI render: default; VCL: osx; 
Locale: en-US (en_US.UTF-8); UI-Language: en-US
Calc: threaded
Comment 10 johnks 2022-05-12 14:23:00 UTC
 download from https://www.gst.gov.in/download/gstr4/offline

unable to upload here as the file is too big


this excel file opens on the first sheet, throws bunch of errors and refuses to quit. i had to do multiple times alt-f4 and then i somehow got the quit dialog open.

the macros that are not implemented in calc make this file unusable to even open

Version: 7.3.3.2 / LibreOffice Community
Build ID: d1d0ea68f081ee2800a922cac8f79445e4603348
CPU threads: 4; OS: Linux 5.13; UI render: default; VCL: gtk3
Locale: en-IN (en_IN); UI: en-US
Flatpak
Calc: threaded
Comment 11 QA Administrators 2024-05-12 03:16:16 UTC Comment hidden (obsolete)
Comment 12 Gigi GD 2025-07-23 16:23:57 UTC
Tested it on LO 

Version: 25.2.5.2 (X86_64) / LibreOffice Community
Build ID: fb4792146257752f54eab576deb869869b108571

The described effect is still there, but only if the security-settings for macros in LO are set to medium (and confirming to use macros) or low.

The effect is:
--------------
There is Basic-Code in Modules. That Basic-code has errors on compiling (syntax-error). After confirming those errors inside the Basic-Editor-GUI by clicking on "OK" one can work inside the Basic-Editor-GUI without problems. Clicking on the Calc-Workbook itself leads to the result, that the Calc-GUI is shortly displayed but then the Basic-Editor-GUI appears again, showing a syntax-error, which needs to be confirmed by clicking "OK".


Concerning THIS XLS-File
-------------------------
The first reason why there are basic-compiler-errors in this XLS-File is, that the #if #else #endif-directive from VBA is used. LO-Basic does not have preprocessing-directives, so the code can't work. 
Although LO ignores the #if-statement and does not complain about it, the effect is, that the statements in the #if part is executed just as well as the statements in the #else-part. 
In this case the result is, that a type-definition for "utc_ShellResult" is being executed two times, which result to an error.

The question is: why this code is executed at all ?

Answer: There is Workbook-specific Basic-Code because of the procedures "Workbook_Activate()" and "Workbook_Open()". 

If those procedures are existing, then LO has to call them when somebody tries to view or work on a sheet. 

But in order to call them, they have to be compiled. 

I guess, LO needs to compile ALL the code inside the file, to make sure, that the code works, because you never know, which procedures are being called from inside of "Workbook_Activate()". 
And on compiling the code inside the modules, errors occure. 

So the process is :

1. LO opens file
2. Calc-GUI is shown
3. Workbook_Activate() or Workbook_Open()-function is found in workbook-specific code
4. LO-Compiler tries to compile ALL the Basic-Code
5. Error inside the code of the modules
6. Basic-Editor-GUI is opening and error-position is displayed
7. Basic-Editor-GUI wants a confirmation of user by clicking "OK"
8. User jumps back to Calc-GUI
9. Jump to Step 3 (Workbook-specific code is found) => loop 

As soon as those procedures Workbook_Activate() or Workbook_Open() are existent and there is any error in Basic-Code inside of modules, then the described behavior occurs. 

That behavior is not specific to this XLS-file, it is a general behavior of LO and can be reproduced by 
a very simple file.

The question is : is that a bug  ? 

In order for LO to compile the workbook-specific-code, obviously LO needs to compile all the Basic-Code.
I would not consider this a bug. LO is not crashing but with this constellation, it's just that you can't continue to
view or work in the calc-sheets.

Workaround: how do you close LO when it shows this behavior ?
1. Move the mouse at the bottom of the surface, where all the running programs/apps are shown. There you could close LO, using the operating-system functionality (on linux and windows)
2. That problem doesn't occur, if you set the macro-security-settings to high or very-high. Then the macros in this XLS-File are being deactivated.