How to record a macro for text to columns?

the macro gets recorded but never executed if run…

You should put some effort into your post. You could at least post the recorded code.

You shouldn’t record macros in OpenOffice or LibreOffice. Or write them. Leave that to the experts, :frowning:

That said, here’s a sample:

    sub two_columns_2
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(7) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Columns"
args1(0).Value = 3 : REM number of columns goes here
args1(1).Name = "RegionName"
args1(1).Value = "Section2"
args1(2).Name = "RegionCondition"
args1(2).Value = ""
args1(3).Name = "RegionHidden"
args1(3).Value = false
args1(4).Name = "RegionProtect"
args1(4).Value = false
args1(5).Name = "LinkName"
args1(5).Value = ""
args1(6).Name = "FilterName"
args1(6).Value = ""
args1(7).Name = "SubRegion"
args1(7).Value = ""

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


end sub