I like to use a macro to insert the current date in documents, formatted as “Friday, 31 December 1999”.
Using LO 6 I had a macro to do this easily, with an assigned shortcut key.
After upgrading to LO 7.4.5.1, my macro now inserts a numeric value, not a date.
Please, what formatting instruction do I need to include in the macro to help this work as intended ?
sub InsertDate
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 oLocale as object
oLocale = ThisComponent.CurrentController.GetViewCursor.CharLocale
dim nFmtId as Long
nFmtId = ThisComponent.NumberFormats.queryKey("DD/MM/YY", oLocale, False)
if nFmtId = -1 then
nFmtId = ThisComponent.NumberFormats.addnew("DD/MM/YY", oLocale)
end if
rem ----------------------------------------------------------------------
dim args2(5) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Type"
args2(0).Value = 0
args2(1).Name = "SubType"
args2(1).Value = 0
args2(2).Name = "Name"
args2(2).Value = ""
args2(3).Name = "Content"
args2(3).Value = "0"
args2(4).Name = "Format"
args2(4).Value = 10079
args2(5).Name = "Separator"
args2(5).Value = " "
dispatcher.executeDispatch(document, ".uno:InsertField", "", 0, args2())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:InsertPara", "", 0, Array())
end sub