Test code not working to open dialog.in 24.2.5.2

Hi
Trying this code to open a dialog but get a message : variable not defined.

<Option Explicit

Sub MinimalTest()
MsgBox “Hello, World!”, vbInformation, “Test”
End Sub> Blockquote

What do I need to add.

LinuxMint 21.3
LO Calc 24.2.5.2

Thanks
Charles

Sorted it. Removed Option Explicit.

Why would this be?
Thanks
CharlesOption Explici

Try to read the error message:

A type for the variable ?

Just google, to find the help file I linked below.
The more important question: Where did you find your “Test code”. “vb” seems to hint on MS Visual Basic…

https://help.libreoffice.org/latest/ro/text/sbasic/shared/03103300.html

Interestingly (enough), the code below works fine…

Option VBASupport 1

Sub vbTEST

MsgBox "Hello, World!", vbInformation, "Test"
MsgBox "Hello, World!", vbQuestion, "Test"
MsgBox "Hello, World!", vbExclamation, "Test"

End Sub

Exactly - because on of the main functions of Option VBASupport is to introduce VBA-specific names.

And without VBASupport one would use the StarBasic MB_ constants for the assorted buttons.

Explanation for OP. Without VBASupport enabled, vbInformation is seen as an undefined variable by StarBasic and hence throws an undefined variable error if Option Explicit is enabled.

By “interestingly (enough)” I meant that the LO Help does not mention those constants in Additional VBA constants.

1 Like

Ah - good catch. Would you file a documentation bug please?

Here you are: tdf#162226

2 Likes