Page 1 of 1

Enter date and time macro

Posted: Sat Jun 17, 2017 8:58 am
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

Re: Enter date and time macro

Posted: Sat Jun 17, 2017 9:38 am
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.

Re: Enter date and time macro

Posted: Sat Jun 17, 2017 9:45 am
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)

Re: Enter date and time macro

Posted: Sat Jun 17, 2017 11:07 am
by Villeroy
First of all, you have to install MRI: [Tutorial] Introduction into object inspection with MRI