Hi
I’m new to OnlyOffice, just done a flathub install on a new CentOS 8 linux setup (my first time with Centos too!).
I want a macro to to set a comment in a cell / replace existing comment if there is one. I came up with this…
(function()
{
oWorksheet = Api.GetActiveSheet();
oActiveCell = oWorksheet.GetActiveCell();
oComment = oActiveCell.GetComment();
if ( oComment.GetText() === "" ) {
oActiveCell.AddComment("Comment 1");
} else {
oComment.Delete();
oActiveCell.AddComment("Comment 2");
}
})();
If I run this on a cell with a comment already present then the comment is deleted and the new comment (“Comment 2”) is added to replace it. But, if there isn’t a comment already there then the “Comment 1” comment doesn’t get added. I can’t work out why that doesn’t work.
Additionally, I would like this macro to be run automatically when a cell in a range has a new value entered by the user (I have a macro in Excel for this that I wrote a few years ago). Is that possible with OnlyOffice?
Thanks