Ask Your Question
0

How to on open Writer document form Date Field display current date

asked 2016-08-30 11:20:39 +0100

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

How to on open Writer document form Date Field display current (OS) date? (The document is opened from template.) I can set "Default date" but it's static date. I'd like to provide current date to document user so she/he can leave it or change it.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2016-09-01 09:36:10 +0100

Darek gravatar image

Thanks to Villeroy -> [Solved] Date Field can't set date I managed to set it via macro:

Sub SetDefaultDate(ByVal DateFieldName As String)
    oForm = ThisComponent.drawpage.forms(0)
    oElm = oForm.getByName(DateFieldName)

    strDigits = CDateToIso( Date() )
    oDate = createUnoStruct("com.sun.star.util.Date")
    oDate.Year = cInt(left(strDigits,4))
    oDate.Month = cInt(mid(strDigits,5,2))
    oDate.Day = cInt(right(strDigits,2))
    oElm.Date = oDate
End Sub

Sub TestSetDefaultDate
   SetDefaultDate("Date Field 1")
End Sub
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-08-30 11:20:39 +0100

Seen: 128 times

Last updated: Sep 01 '16