Page 1 of 1

Inserting the date each day in a journal

Posted: Mon May 10, 2010 12:02 am
by mkhammer695
Thanks. I guess I am in over my head but I seem to learn faster this way.
The machine is running Windows Vista 32 bit and I have been struggling with the issue for the better part of six hours. Plus a few days.
In OpenOffice.org 3.2 Writer, I have been developing a "Journal" template.
This is when the trouble started. It is very handy to have a tool by which the "Date" in the date field changes with the calendar, but now I've got the bright idea that it would be very helpful to set it up so that a time stamp would be set in a field upon opening the document, saving it, and closing it.
This way I would have a detailed record of events in the journal.
I checked the "Macros" forum entries and tried a copy/paste dialog. It inserted the time field but it updates the time at the upper left whenever I re-open the journal. The message pops up SYNTAX ERROR and I have to click close four or five times to escape.
Does anyone know how to configure the time stamp to anchor the appropriate field after the ending sentence on "close" or "save", and in front of the opening sentence when opening the journal?
for example: 13:33:50 The quick brown... the end of that. 13:56:04
I appreciate your willingness to school me in this if someone is willing and able.

Best vibes
Hammer

Title Edited. A descriptive title for posts helps others who are searching for solutions and increases the chances of a reply (Hagar, Moderator).

Re: macros-snippets-scripts-or?

Posted: Mon May 10, 2010 12:13 am
by RoryOF
If you select Insert / Fields / Other / Document / Time
you get two choices, Time (fixed) and Time. Time fixed freezes the time of insertion, Time updates.
The shortcut Time selection from Insert Fields is the updating one.

I can't help with your time-stamping, sorry.

Re: macros-snippets-scripts-or?

Posted: Mon May 10, 2010 12:17 am
by floris v
Insert - Field - Document tab - select Time. That should give two options, Time (fixed) and Time. You need Time (fixed).

Code: Select all

sub insert time
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 args1(5) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Type"
args1(0).Value = 1
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 = 5041
args1(5).Name = "Separator"
args1(5).Value = " "

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