Errors with a macros enabled document

Community,
There is this document that we use to file our local taxes however the document just crashes and generates lots of errors. Have tried using it several times using libre but it just not work, no matter the libre version.
Can anyone look at the file and try to figure out whats wrong.
VAT3_Return.ods (154.8 KB)

Hello,
More information may be of help. Have downloaded the file to Ubuntu 20.04 with LO 7.3.4.2 and it opens without issue. What OS and specific LO version are you using? Under what circumstances are you getting errors and crashes?

Okay. Let me break it down. Opening the doc has no issue. Use the below steps to recreate the issue:
under personal identification number enter the number: P051725476R(it can be any number but it has to start with a P and it end with a letter and be the same length)
Type of return: Original
Entity type: Head office
Return period: 01/06/2022
Return period: 30/06/2022, but at this point is where it crashes and takes me to recovery mode.

Am using linux mint 20.3 cinnamon, kernel 5.4 and libre office 6.4.7.2,

Yeah that’s the thing, once the crashes start they continue even on the next page, there it becomes more problematic, if you can, go to the next page and try to fill in something, am sure the errors will pop up. Thanks for checking on it tho…

just crashes and generates lots of errors.

Do not see this. Do not have definitive answer but a direction for you at this time.
.
Upon entering the Return Period is where the crash occurs. Once recovery is complete, the date is still there and causes no further crash. Can even re-enter the date without issue. Commenting out this line in AddListener sub:

call addKRAListnersSingleCell("A_Basic_Info","SecA.RtnPdFrom","rtnPeriodFrom_",rtnPeriodFrom_Listener,rtnPeriodFrom)

.
stops the crashing (of course it is a necessary line for date checking).
.
That is all I have time for right now.

No - not getting errors but can’t enter pin either - have none. Can enter other fields without issue. This all seems to be some issues with all the listeners installed through code. Will take research and have seen some similar postings on this previously.
.
May have some time later or someone else may spot something.

Sorry but this is confusing. If you use it to file taxes but appears not to work (ever?) where did you get it from? Has it ever worked? If so under what circumstance?

We get it from our local government site. There are normally 2 versions of the same doc, an MS Excel version(xlsm) and the ODS version. The xlms version works just find on Excel but does not function on libre. And no it has never worked on libre.

Ohh, whoever had created that garbage code, they made a lot of effort to make others suffer.

Starting with missing proper recovery. E.g., rtnPeriodFrom_modified calls

	thisComponent.CurrentController.Frame.ContainerWindow.Enable= False
	call removeKRAListners(rtnPeriodFrom_Listener,rtnPeriodFrom)

and when an error happens in the code below, the final

	call addSectionCListeners()
	call addSectionGListeners()
	call addKRAListnersSingleCell("A_Basic_Info","SecA.RtnPdFrom","rtnPeriodFrom_",rtnPeriodFrom_Listener,rtnPeriodFrom)
    thisComponent.CurrentController.Frame.ContainerWindow.Enable= True

get skipped. An advice for whoever decides to debug: add a function like

sub PoorManSubstituteForProperRecovery
	call addSectionCListeners()
	call addSectionGListeners()
	call addKRAListnersSingleCell("A_Basic_Info","SecA.RtnPdFrom","rtnPeriodFrom_",rtnPeriodFrom_Listener,rtnPeriodFrom)
    thisComponent.CurrentController.Frame.ContainerWindow.Enable= True
end sub

and call it when a macro gets interrupted because of an error.

I will even skip the wrong leap year checking code, insane copypasta everywhere and not using proper methods (all the date checking could be simplified using DateSerial and Day+Month+Year). But the code also relies heavily on specific locale settings, like using / for separating date parts. E.g., checkFutureDate uses this:

currDate= Split( Format(Now(), "dd/mm/yyyy"),"/")
If yr= INT(currDate(2)) then
	...

This is simply wrong, because Format(Now(), "dd/mm/yyyy") is not what author thought it was. E.g., for my locale, Format(Now(), "dd/mm/yyyy") will produce 01.07.2022 (note dots as date part separators!). That is because the / is not a literal character in the format code, it is a special character, meaning “locale-defined date separator”. So if your locale doesn’t use /, the following Split will create a single-value array, and the next currDate(2) trying to access third element from there will naturally fail. Again, plain Year on Now would make it safe.

Honestly, I stopped debugging this after seeing how much effort will it take. Sorry.

1 Like

Tar and feather them.

1 Like