So, das fertige Makro möchte ich Euch natürlich nicht vorenthalten:
Code: Alles auswählen
sub Fristsetzen
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")
oVC = ThisComponent.getCurrentController.getViewCursor()
If oVC.ParaStyleName = "Frist" then
rem Datum ändern
rem altes Datum entfernen ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:WordLeftSel", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:WordLeftSel", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:WordLeftSel", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:WordLeftSel", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:WordLeftSel", "", 0, Array())
rem neues setzen----------------------------------------------------------------------
Dim oFristDate as String
Dim oWD as String
Dim oformerFristDate as String
oformerFristDate = oVC.string
'oFristDate = DateAdd("d", 7, oformerFristDate)
'oWD = WeekDay(oformerFristDate)
oFristDate = DateAdd("ww", 1, oformerFristDate)
'If oWD = 6 then oFristDate = DateAdd("d", 5, oformerFristDate)
'If oWD = 2 then oFristDate = DateAdd("d", 2, oformerFristDate)
dim args7(0) as new com.sun.star.beans.PropertyValue
args7(0).Name = "Text"
args7(0).Value = oFristDate
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args7())
rem außerhalb der Absatzvorlage Frist
else
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:InsertPara", "", 0, Array())
rem ----------------------------------------------------------------------
dim args2(1) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Template"
args2(0).Value = "Frist"
args2(1).Name = "Family"
args2(1).Value = 2
dispatcher.executeDispatch(document, ".uno:StyleApply", "", 0, args2())
rem ----------------------------------------------------------------------
oFristDate = DateAdd("ww", 1, Date)
'oWD = WeekDay(oFristDate)
'If oWD = 7 then oFristDate = DateAdd("d", -1, oFristDate)
'If oWD = 1 then oFristDate = DateAdd("d", 1, oFristDate)
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "Text"
args3(0).Value = oFristDate
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args3())
endif
end sub