Incrementing the space before a paragraph

I created the first macro below in VBA to increase the Space above a paragraph by two points. It reads the current space above the paragraph add add2 points to that value. I got it to be this simple one by recording a macro, then removing the irrelevant items. Every time I run the macro it increases the space above by two more points.
When I did record macro in LO basic what I got is below it. I got some useful info from responses to my previous topic and now
I would like to know:
How I can access the current space above value in LO Basic and and add 2 points to it
What in the very complex LO basic macro is actually irrelevant to getting the result I want and could be deleted
If you are willing to write an LO basic macro that is equivalently simple as the VBA one, I would appreciate your doing so.
Finally where can I find
1) documentation of the terms I’ve bolded in the LO macro
2) what the VBA equivalent to these and other LOTerms.
VBA Macro
Sub SpaceBeforeIncrease()

With Selection.ParagraphFormat
.SpaceBefore = .SpaceBefore + 2
End With

End Sub

LO Macro
sub SpacebeforeIncreaseLO
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(4) as new com.sun.star.beans.PropertyValue
args1(0).Name = “TopBottomMargin.TopMargin”
args1(0).Value = 101
args1(1).Name = “TopBottomMargin.BottomMargin”

args1(1).Value = 0
args1(2).Name = “TopBottomMargin.ContextMargin”
args1(2).Value = false
args1(3).Name = “TopBottomMargin.TopRelMargin”
args1(3).Value = 100
args1(4).Name = “TopBottomMargin.BottomRelMargin”
args1(4).Value = 100
dispatcher.executeDispatch(document, “.uno:TopBottomMargin”, “”, 0, args1())
rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = “NumberingStart”
args2(0).Value = false
dispatcher.executeDispatch(document, “.uno:NumberingStart”, “”, 0, args2())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = “NumNewStartAt”
args3(0).Value = 65535 what does this mean?
dispatcher.executeDispatch(document, “.uno:NumNewStartAt”, “”, 0, args3())

end sub

Note that your question lacks 2 very important pieces of information: OS name and LO version.

Why would you write such a macro when you can solve the problem very elegantly by styling your document and later modifying your Spacing above in the paragraph style configuration?

It is simpler, more straightforward and in line with Writer approach based on styles.

3 Likes