Hello @WhiteBear, follow example file.
With Macro and Menu to trigger.
sub dddd
rem ----------------------------------------------------------------------
dim document, dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(5) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Type"
args1(0).Value = 0
args1(1).Name = "SubType"
args1(1).Value = 0
args1(2).Name = "Name"
args1(2).Value = ""
args1(3).Name = "Content"
args1(3).Value = "0"
args1(4).Name = "Format"
args1(4).Value = 10107
args1(5).Name = "Separator"
args1(5).Value = " "
dispatcher.executeDispatch(document, ".uno:InsertField", "", 0, args1())
dispatcher.executeDispatch(document, ".uno:WordLeftSel", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:Cut", "", 0, Array())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "SelectedFormat"
args3(0).Value = 1
dispatcher.executeDispatch(document, ".uno:ClipboardFormatItems", "", 0, args3())
dispatcher.executeDispatch(document, ".uno:InsertPara", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:InsertPara", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:InsertPara", "", 0, Array())
end sub
Edit 06/04/2020
Sub InsertDateNow
dim args1(5) as new com.sun.star.beans.PropertyValue
args1(2).Name = "Text" : args1(2).Value = Format(Now(),"YYYY.MM.DD")
CreateUnoService("com.sun.star.frame.DispatchHelper") _
.executeDispatch(ThisComponent.CurrentController.Frame, ".uno:InsertText", "", 0, args1())
End Sub
ATTENTION: If you would like to give more details to your question, use edit in question or add a comment below. Thank you.
If the answer met your need, please click on the ball to the left of the answer, to finish the question.