VBA time stamp in java script

Hey there,

I need help converting a VBA code into only office macro (java script).

VBA:
Sub Neu()
Dim zeit As String
zeit = Right(Now(), 8)

ActiveCell.FormulaR1C1 = zeit
Selection.NumberFormat = "hh:mm:ss"

End Sub

In Excel I can use this VBA to output the current time by clicking on a linked button (form).
Can anyone help, how to use this code in onlyoffice?

Kind regards

Hello @BB1234

To insert time in hh:mm:ss format you can use this macros:

(function()
{
    var date = new Date();
    var hours = date.getHours();
    var minutes = date.getMinutes();
    var seconds = date.getSeconds();
    Api.GetActiveSheet().GetActiveCell().SetValue(hours + ":" + minutes + ":" + seconds);
})();

You can assign created macros to the image so you can execute it upon clicking on it:
https://api.onlyoffice.com/plugin/writingmacros#assign-macro

Hello @Constantine
Thank you so much!

You are welcome!