Input today date if change

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
msalsinha
Posts: 5
Joined: Wed Oct 19, 2016 12:48 pm

Input today date if change

Post by msalsinha »

Hello

I wanted to create a function or a macro that whenever I modify a certain cell with a certain content it marks the date of today without coming back to update unless I change the contents of the cell again.

Can someone help me?
OpenOffice 4.1.3 on Windows
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: INPUT TODAY DATE IF CHANGE

Post by Zizi64 »

You can use a form control element for the value modification. In this case you can assign your timeStamp macro to the "click on" event of the form control element. Or you can create a listener (changed event) for the cell. Search the word "Listener" in the macro forum.

Note:
A click on the form control element not will always mean : "The cell content is changed", as the manual input (typing some data into a cell) not always mean : "The cell content is changed", because you maybe typed in same value as the cell was contained. But the event will activated, when you edit a cell. My opinion you need store the previous content of the examined cell (into a global macro variable) for the exact detecting of the change.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
msalsinha
Posts: 5
Joined: Wed Oct 19, 2016 12:48 pm

Re: INPUT TODAY DATE IF CHANGE

Post by msalsinha »

Let me demonstrate what exactly I try to do.

Whenever in the "ESTATE" column I change the state of each cell, in the "DATE" column will appear the date when the change was made.

Image
Attachments
EXAMPLE.ods
(9.47 KiB) Downloaded 224 times
OpenOffice 4.1.3 on Windows
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Input today date if change

Post by Villeroy »

menu:Tools>Options...OOoCalc>Calculate: Enable iteration with 1 step

Code: Select all

=IF(A1="";"";IF(B1="";NOW();B1))
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Input today date if change

Post by Zizi64 »

Listener example:
viewtopic.php?f=20&t=30516
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Input today date if change

Post by Zizi64 »

A simple example with Combobox and macro:
DateTime of change.ods
(13.75 KiB) Downloaded 217 times
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Input today date if change

Post by Zizi64 »

Modified example. The scope of the macro is limited to the cells have custom cell style, named "InputCells".
DateTime of change2.ods
(14.02 KiB) Downloaded 228 times
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Post Reply