Macros stopped working

In the last few months, my previously functioning Writer macros stopped working, giving only:
BASIC syntax error.
Expected: Sub.
for each macro in turn (it seems to try to run them all).

At the same time, the "Record Macro’ option is missing from the Tools | Macros menu (there’s only Run, Edit, Organize.

Setting Tools | Options | Security | Macro Security down even as far as ‘Low’ doesn’t resolve it.

I assume this is down to an update, but can’t pin it down.

Windows 10
LO 7.1.5.2 (x64)

Here’s an example of one recorded macro that’s intended simply to insert an em-dash when a key is pressed:

sub emDash
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 ----------------------------------------------------------------------
dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Symbols"
args1(0).Value = "—"

dispatcher.executeDispatch(document, ".uno:InsertSymbol", "", 0, args1())

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


end sub

Check whether Tools -> Options -> LibreOffice -> Advanced -> Option: [x] Enable macro recording (may be linited) is set.

Thanks! That did solve the recording option issue; didn’t know that was there. I’m not sure why my old macros aren’t working, but at least now I can record new ones.

Checked your macro on my Windows 10, LibreOffice 7.1.5.2 and it works for me. From your error message and the fact, that you need to re-enable recording option, I’d conclude:

You recently reset your LibreOffice user profile and made a typo when recreating the macros and missed to type sub BASIC key word. Please check, whether you have emDash instead of sub emDash.

I couldn’t find an obvious error in the macros in that module, but I decided to simply delete all of them and start over with the recorded macro, and it now works fine, so there must have been an error somewhere. (I think some may have had ‘Sub’ instead of ‘sub’, if that matters). In any case, thanks for the tip.