Locking specific content

Do you want to: Ask a how-to question
DocumentBuilder version: 6.4.0-121
Installation method: Installing ONLYOFFICE Docs for Debian, Ubuntu, and derivatives - office en ligne with Nextcloud integration
OS: Ubuntu 18.04

Hi all,

I am trying to achieve the following:

  • First, I would like to write a macro to lock some cells or columns, so they can’t be edited (while the macro is active). I understand that in Excel this is possible using the following command:
Range(Target.Address).Locked = True

In OnlyOffice, I tried the following, but it didn’t seem to work:

(function()
{
    // Getting the active sheet
    activeSheet = Api.GetSheet("Bons expés");
    activeSheet.GetRange("C2").Locked = true;
})();

I went through the API, but couldn’t find a method to do that. Is it possible?

  • Second, I would like to prevent users from pasting on a specific worksheet. It is possible in Excel to do so using the following code : http://www.vbaexpress.com/kb/getarticle.php?kb_id=373 . However, I couldn’t find a way in the API to perform this action. Does such a way exist?

Thanks for your help.
Best,
Jessica

Hello Jessica,
Sheet/cell protection is not yet supported by the Document Server, so there are no methods for that. This feature will be implemented in Document Server 6.5 that will be released in several months (no exact time frames yet). Sorry for the inconvenience.

1 Like

Hello Carl,

Thanks a lot for your quick reply. I will look forward the new version in this case :slight_smile:

Best,
Jessica

1 Like