Why can't I run a simple macro?

When I record a simple macro and try to run it I get the following:

BASIC syntax error.
Expected: Sub.

I have written no code at all. The macro I am trying to record and run involves merely pressing the pgdn key three times.

The Options|Libre Office|Advanced page shows that both macro recording and experimental features are supported.

I am running Windows 10 Pro Version 21H1 and LibreOffice 7.1.4.2

I ask again, What am I doing wrong.

What am I doing wrong?

Hello,

What am I doing wrong?

Can’t tell exactly as you have provided very little information.

I can get the same error if trying to execute code in the Basic IDE where there is no definition of Sub or Function.

It would be nice if you would edit your question (please do not use an answer) and add the code you have along with OS and LO version and what you want to accomplish.

What am I doing wrong?

Asking a bad question.

When you are asking questions about code, you must always show the code.

P. S. And yes, error messages from the LO Basic engine are uninformative in most cases.

I am using an installed and updated Java runtime environment

How JRE is related to Basic macro recorder?

Hello,

Not certain what you did. I recorded this and it works fine:

sub pgdn
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:PageDown", "", 0, Array())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:PageDown", "", 0, Array())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:PageDown", "", 0, Array())


end sub

You should look at the documentation. See → Getting Started with LibreOffice. Look at Chapter 13 Getting Started with Macros. Has a section on Recording a Macro.