Page 1 of 1

Random error messages

PostPosted: Sat Mar 06, 2021 12:54 pm
by Crisdeannn
Hello,

For few days I struggle with strange behaviour of the editor.

Probably it started since I had downloaded additional dialog window from another spreadsheet and made few changes in the sequence of first functions in the code.

When I start a macro, it breaks and I am getting random and pointless error notifications.

For example:

for line:
dim oWindow as object
"Inadmissible value or data type.
Index out of defined range."

for line
oSheet = ThisComponent.Sheets(4)
"BASIC runtime error.
Object variable not set."

for line:
if parameter = 0 then
"BASIC runtime error.
Object variable not set."

etc.

Sometimes all I need to do to solve that issue is to close and open the spreadsheet or to place a line with MsgBox() function before the line which was a subject of an "error", for example:

MsgBox("Hello")
dim oWindow as object

Such "solution" works for a while but soon these issues return in different code line.

Since I don't even know how to define the problem, I could not find any solutions, but it looks like a general issue that should have happened to other users by now. Do you have any suggestions ?

Thank you

Re: Random error messages

PostPosted: Sat Mar 06, 2021 12:58 pm
by RoryOF
I think we need to see the full text of the macro.

Re: Random error messages

PostPosted: Sat Mar 06, 2021 2:09 pm
by JeJe
Try a search for all the other instances of the variables you're having problems with to see if there are any conflicts/duplications. If you have a function or another variable also called oWindow you can have problems. It could be in an extension or it could be in the built in OO macro libraries.

Re: Random error messages

PostPosted: Sat Mar 06, 2021 2:20 pm
by JeJe
Or just try changing the names to something less generic.

Re: Random error messages

PostPosted: Sat Mar 06, 2021 6:56 pm
by Crisdeannn
RoryOF wrote:I think we need to see the full text of the macro.


The macro has more than 28.000 lines and, unfortunately, I am not allowed to publish the whole code. It is also impossible to choose problematic parts, because error messages seems to appear randomly in unpredictable parts of the code. I suppose that studying it would not lead to the answer...

JeJe wrote:Try a search for all the other instances of the variables you're having problems with to see if there are any conflicts/duplications. If you have a function or another variable also called oWindow you can have problems. It could be in an extension or it could be in the built in OO macro libraries.


JeJe wrote:Or just try changing the names to something less generic.


All variable and function names are uniqe. They worked fine before I made a change that caused the problem. I think the code and variable names are not the issue.

To give you better understanding of what is going on, I'll describe what I did in last minutes and how I "solved" the problem.

I was trying to shorten the code to recreate these errors on short code version. I removed first two functions (which were not important) and the macro started without any error notifications. After pressing one of the keys in dialog window it broke again with another issue:

for line:
z=2
"BASIC runtime error.
Object variable not set."

Before z=2, I just added "dim z as integer" and restrated the macro. Now it didn't even start (so the situation got worse) but broke on a line of different routine:

for line:
if parametry_pierwotne = 0 then
"BASIC runtime error.
Object variable not set."

Before this line I added empty line (just by simply pressing enter) and restarted macro again. Now it works fine and do not crush. Everything seems to be perfect.

When changing the code I was also getting error messages like:

for line:
MsgBox("Start")
"BASIC runtime error.
Sub-procedure or function procedure not defined."

or for line:
Start_dialog_0
"BASIC runtime error.
Property or method not found: ᤀ禁€ऀ." (yes, with these funny characters)

As you can see these errors seem to make no sense. I wonder what can cause the program to behave like that.

Re: Random error messages

PostPosted: Sat Mar 06, 2021 7:37 pm
by RoryOF
It is my memory (perhaps faulty) that there is a limit of 64KB to an OpenOffice macro code module - perhaps also to a LibreOffice macro code module. If you have 28,000+ lines, that only allows 2.5 characters per line. So if my memory is correct (not checked) you may need to break your code into modules. But I am not an expert macro writer, so someone with more experience may have other suggestions to offer.

Re: Random error messages

PostPosted: Sat Mar 06, 2021 8:46 pm
by Crisdeannn
RoryOF wrote:It is my memory (perhaps faulty) that there is a limit of 64KB to an OpenOffice macro code module - perhaps also to a LibreOffice macro code module. If you have 28,000+ lines, that only allows 2.5 characters per line. So if my memory is correct (not checked) you may need to break your code into modules. But I am not an expert macro writer, so someone with more experience may have other suggestions to offer.


Considering what errors I get, that could be the reason. I have checked that and OpenOffice wiki states that modules within libraries have a maximum size of 64kb.

I have it in one module and the code contains 620.000 characters (665 kB in notepad).

However, I have experienced this problem just for few days. Last week macro versions have over 600.000 characters, which means that they exceed 64kb limit 10 times and still work fine.

I will try to split the code in few modules and let you know if the problem reoccur.

Re: Random error messages

PostPosted: Sat Mar 06, 2021 9:35 pm
by Villeroy
The macro has more than 28.000 lines

And why do you need any help from us? You are the expert. You have the code.