I often want to keep a paragraph with the next paragraph. How to create a macro to do this in LibreOffice Writer?
There are two ways, cut and paste the macro below, or alternatively record a macro. Before a macro can be recorded, however, it must be enabled following the instructions by going into Tools > Options > Advanced and enabling macro recording.
A macro to set the Keep With Next attribute of a paragraph is as follows:
sub ParagraphKeepWithNext
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(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ParaKeepTogether"
args1(0).Value = true
dispatcher.executeDispatch(document, ".uno:ParaKeepTogether", "", 0, args1())
end sub
Recent Comments