VBASupport 1 not working at all

I’m trying to use VBASupport 1 to use some old VBA macros. However, it doesn’t seem to be… activating?
Even the example program at Option VBASupport Statement is giving a runtime error

Has VBASupport1 been deprecated or updated recently? Is this some sort of permissions or settings issue?
I’m using linux mint libreofficecalc version 24.2.7.2, but someone with a mac checked for me and are getting the same issue.

Edit: Have also tested on 26.8 on mac now, same result

The content of the variable sVar is an OBJECT. (A programming object.) You can not “print” it. Get a property of the cell range firstly, and then try to print the property.

This VBA-Garbage works for me only with NO or NUMERICAL Content in Sheet1.A1, BUT NOT with TEXT-content! or especially if THERE IS NO »Sheet1«

Version: 26.8.0.3 (AARCH64)
Build ID: bce0998afefdbc355585ca324285661a2170ba77
CPU threads: 4; OS: Linux 6.18; UI render: default; VCL: gtk3
Locale: de-DE (de_DE.UTF-8); UI: en-US
Calc: threaded

?? sVar is declared as “single” two lines before print. So it should not receive an “OBJECT”.

With the declaration printing should be no problem.
The question is, what sVar receives. And for @CyreneDuVent it receives nothing, because the error occurs before sVar receives a value.

And I guess @karolus is right. @CyreneDuVent may not use an english locale, so the existence of Sheet1 should be checked. That would fit the error-message perfectly.

Let’s check it together using the attached file.
I don’t have an error.

Version: 26.2.5.2 (X86_64)
Build ID: cd7284b4cbbfeb507e630c1aac019f4157393acb
CPU threads: 6; OS: Windows 10 X86_64 (build 19045); UI render: Skia/Raster; VCL: win
Locale: ru-RU (ru_RU); UI: ru-RU
Calc: CL threaded

ExampleVBA.ods (7.8 KB)

In VBA, objects can have default properties. Since we do not use the Set operator for the assignment, the construct used is equivalent to

sVar = Application.Worksheets("Sheet1").Range("A1").Value

or in even greater detail

sVar = Application.ActiveWorkbook.Worksheets.Item("Sheet1").Range("A1").Value(xlRangeValueDefault)

:slight_smile:

of course not, because »Sheet1« exists and Sheet1.A1 content is numeric!

However, the initial message reveals an error of a different nature.
Such an error can occur, for example, if the Basic module is placed in the application library (My Macros…) rather than in the document itself.
I hope the author of this thread tests my document so we can pinpoint the issue.

Indeed.

On empty cell / cell with text: macro in Application raises Basic runtime error 35

Macro in document: on empty cell — warning box (value 0), on cell with text: Basic runtime error 13 (Date type mismatch).
⠀
Version: 26.8.0.3 (X86_64)
Build ID: bce0998afefdbc355585ca324285661a2170ba77
CPU threads: 8; OS: Windows 11 X86_64 (build 26200); UI render: Skia/Raster; VCL: win
Locale: en-US (it_IT); UI: en-US
Calc: threaded

This happens when Sheet1 exists, and with numeric content in sheet 1 A1. I am running this from the My Macros section rather than it being placed in the document, so if that changes behaviour that very well may be it. Will test now.

The attached file is not giving an error, so it seems like the macro location may be the issue. Will test a couple more cases now

That explains everything.
In none of the LibreOffice versions known to me will such a macro—if placed in the application library (My Macros…)—work.
It is only within a Calc document that the Worksheets construct is interpreted as Application.Worksheets, where Application is a special object.

1 Like

Final conclusion: The issue is solved by running the macro from within the workbook instead of the library. Thank you @sokol92 !

2 Likes