How does one interrupt a running macro?

I’m studying LibreOffice Basic for macros. I have a long-running macro which, once I determine a bug, I would like to abort the macro. I’ve tried CTRL-C but that does not work. I’m running on Linux, if that matters. I am grateful for any insight into this issue.


Much of the information regarding LO can be found in the many locations of LO help. Off-line help (if you installed it) states to use Ctrl+Shift+Q from within the Basic IDE. Shift+F5 also works in the IDE as well as pushing the Stop Macro toolbar button.

If this answers your question please tick the :heavy_check_mark: (upper left area of answer). It helps others to know there was an accepted answer.

This is the correct answer. Although it’s in the offline documentation, I could not find it online. The only official information online is the bug report at 70598 – Basic IDE - no way to stop a macro in an infinite loop.

For online see the 5.4 Help which came from here. The Shift+F5 came from hovering the mouse over the Stop icon.

Hello @theGeeko61,

For simple debugging i often just use the msgbox() function.

Code execution is halted until the msgbox dialog is dismissed.

So you could temporarily insert the following line into your code, at all places where you would like to be able to stop the macro:

If msgbox( "Should we STOP the Macro here?", 36 ) = 6 Then Stop

HTH, lib

You can add a temporary print statement to your macro. This works much like msgbox but has two option buttons; OK continues but Cancel aborts the macro. I often combine this with xray, which provides the detailed information I need to determine whether I’ve found what I’m looking for but has no abort option. xray object : print. This is especially useful when the time between xray statement invocations is too short for Ctrl+Shift+Q to work.

Pull down “Run”. All your options are there. When done compile, to make sure it still is able to run.
I do very little in Macro’s, but, to go to a macro to work in it. Toos/Macros/edit macros. Then in Object Catalog go to your file, then Standard then your Module, double click your Module or the Sub you are wanting to work in. Seems you already know how to do those steps.
Click in your Sub where you want it to stop, then pull down “Run”. All your options are there. When done compile, to make sure it still is able to run.