Enter date and time macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Fraz627
Posts: 22
Joined: Sat Jun 17, 2017 8:31 am

Enter date and time macro

Post by Fraz627 »

Hi everybody.
First let me tell you that I'm very very new to open office. I need to convert an Excel app to use with open office, so in the future you will be seeing a lot of post.
But for now In the orignal excel app I had a macro activated by ctrl + enter that if the cell is formatted as time it inserts the current time, the same applies for dates.
Also if the Ctrl + enter event happens in certain columns it either increments the value of the previous row, or fill the cell with the previous rows value.

Thanks
Open Office 4.1 on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11352
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Enter date and time macro

Post by Zizi64 »

In the orignal excel app I had a macro
Please upload the macro and or a spreadsheet file with the ebedded macro here.

You must rewrite your VBA macros based on the API function of the AOO or LO. You can use the StarBasic or one of other supported programming languages for the reworking procedure. You must study the API functions, and I recommend Andrew Pitonyak's free books for you.
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: 11352
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Enter date and time macro

Post by Zizi64 »

Here is an example code snippet for inserting a Date/time value into the actual selected cell:

Code: Select all

oCell = ThisComponent.getCurrentSelection()
oCell.setValue(DateValue(Now))

'or for a pure time value:
'oCell.setValue(TimeValue(Now))

'or for a combined Date-Time value:
'oCell.setValue(Now)
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
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Enter date and time macro

Post by Villeroy »

First of all, you have to install MRI: [Tutorial] Introduction into object inspection with MRI
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
Post Reply