Visual basic macro works in Excel but not in Calc

The compiler complains about a syntax error
at the last line of this code snippet
For I = 1 To M + 2
A(I, KP + 1) = -A(I, KP + 1)
Next I
Even when I comment it out, it still stops there and complains.
It has been running just fine in Excel.

Please take a look to this thread:

I added those lines, to no effect. It doesn’t even recognize comments.