Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to create a Macro to insert the current date in the current language.

I write documents in Thai and English sometimes using both in one document. I would like to create a macro to insert the current date for me in whatever language is currently being used in the document. I can do this manually with: Insert > Field > More Fields > Date > Date (Fixed) > Additional Formats > Language = Automatic I created a Macro to do this (see below) but it comes out only in English. What can I do to my Macro to make the date format come out in the language currently being used in the document? How can I insert as a field?

sub Insert_Date
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 sText as string
sText = Format(Now(),"D MMMM YYYY")

dim args1(5) as new com.sun.star.beans.PropertyValue
args1(2).Name = "Text"
args1(2).Value = sText

dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args1())


end sub