Mysterious Runtime Error

I have a macro that used to work. Only recently did this issue first crop up. “oSheet” is a sheet with a single-cell range named “CTE”.

“Result” is an xresultset.

This is part of a section that runs a query and puts a field of the first result into a named cell. There are several other such sections before it that are functioning as intended without throwing any errors.

The line

oSheet.getCellRangeByName("CTE").Value = Result.getFloat(1)

Returns:

BASIC runtime error.
An exception occurred
Type: com.sun.star.uno.RuntimeException
Message: .

What does it mean? :alien:

It means nothing. Attach a file, please.

Love to, but unfortunately, this macro is launched from an .odb file with a MySQL backend and launches a template .ods file, and I’m not sure what to upload so that it can be understood. Here, I’ll try this.
Beginning of Macro.odt (18.5 KB)
EMU Calculations.ods (23.2 KB)

Beginning of Macro contains just that. EMU Calculations is the .ods file it launches.

Sorry, there are others here to help you.

But the general rule is this. You have to execute the code in step-by-step mode, find the line that causes the error, and check the state of the data used in that line.
Check the state of the Result object variable.

Hello,
Using a registered HSQLDB embedded DB , Your Sheet and most of your code placed in the sheet, I have no issues:


.
Your information provided needs more. A sample embedded Base file which can be used to display the problem will be helpful in light of not providing the MySQL files.
.
As you have stated:

.
so something must have changed with your set up.

Please tell me, @agerber85 , you (quite by accident!) don’t have this option enabled?

image

Just a ridiculous assumption: if this box is unchecked, then the name of the last column on the sheet is AMJ and everything is in order. But if the flag is cocked, then among 16 thousand columns we can meet a column with exactly the same name “CTE”. If I were Calc and BASIC, I would get confused and try to give you the whole column CTE1:CTE16000000. And the column does not have the .Value property. Yes, a quick test did not show such a result. But maybe it’s in my version of Calc. By the way, what version do you have?

Thanks, @JohnSUN, but no. I don’t even have that option. (I’m in 7.0.6.2.)

Is the step-by-step mode something I can turn on, or just a way of setting the code up to run? I confess I’ve never heard of it, and Mr. Google is no help on this question.

@agerber85 Okay, I should have asked. However, how difficult is it for you to put such a test - change the cell name in the template file and in the macro code to something long, like “commonTblExp” - will the error disappear in this case?
And one more guess - in which Scope is the CTE name defined? In Document (Global) or for one sheet?

Just see menu Run in IDE or use keyboard or click icons in Macro toolbar

I’m having trouble finding such a button. I’m not sure the macro will run correctly if not launched from a certain form. (Certain variables are defined using “thisComponent”.) Is there a trick to launching from the IDE and having thisComponent point to what it would if launched by an event?

Thanks! It was globally defined, and looking into this made me realize that it was globally defined to point to a cell in a sheet that was deleted earlier in the macro. I know how to correct this problem. I simply need to change that definition to the sheet that won’t be deleted in the template file.

Regardless, I would like to learn more about using single step with watch so that I can less frequently post my macro troubleshooting issues here (and, hopefully, be less annoying to the vigilant members who are always so helpful to me). Is there a tutorial on this somewhere I should be looking at?

Just try it! Open your form, swap window to IDE, set cursor into text of Sub EMU_WorksheetButton and press F8, F8, F8, again, again and again…

A long time ago in a galaxy far, far away, the IDE really thought that ThisComponent was the window from which the macro was run. Now it knows it’s not and uses the previous DOCUMENT (not the IDE window)

Снимок экрана от 2022-05-13 03-17-15
LibOBasic-1-IDE-Flat-Letter-EN-v102.odt (922.5 KB)

And there is:

https://help.libreoffice.org/7.3/en-US/text/sbasic/shared/01050000.html

and:

https://wiki.documentfoundation.org/Documentation/DevGuide/LibreOffice_Basic

and possibly more.

I’m not sure what you’re trying to tell me with this. I don’t have buttons that look anything like any of those (other than I have one with an eye).

I’m trying to work through the tutorial in the developer’s guide, and, frustratingly, I don’t have a single step icon on my Macro toolbar. I even tried adding it, but a search for “single” in all commands yields nothing.

Version: 7.0.6.2 (x64)
Build ID: 144abb84a525d8e30c9dbbefa69cbbf2d8d4ae3b
CPU threads: 4; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: threaded

F8 - Step into.

You may not believe it :laughing:

Thanks! I was afraid I was going to have to upgrade LO or something drastic.

@agerber85, move the mouse pointer to your buttons, and read the tooltips.