[Solved] Sheet protection in Calc

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
DBGarfield
Posts: 2
Joined: Wed Feb 22, 2017 4:16 am

[Solved] Sheet protection in Calc

Post by DBGarfield »

I have a spreadsheet on which I record results of games in a tournament. At the end of the day, I use a macro to sort the players' records to find the winner.

I have the sheet protected so other users can't mess with the calculations. The macro unprotects the sheet, sorts the records, then protects the sheet again.

In the protection step, it brings up a dialogue box for password entry; I'm not using a password and would like the box to not appear. Is this possible?
Last edited by RoryOF on Wed Feb 22, 2017 7:58 am, edited 2 times in total.
Reason: Added green tick. [RoryOF, Moderator]
OOoV3.3 OSVista
FJCC
Moderator
Posts: 9280
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Sheet protection in Calc

Post by FJCC »

This code protects the sheet called Sheet1 without asking for a password.

Code: Select all

oSheets = ThisComponent.Sheets
oSheet = oSheets.getByName("Sheet1")
oSheet.protect("")
If you have trouble integrating that into your code, please post your code so we can make suggestions.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
DBGarfield
Posts: 2
Joined: Wed Feb 22, 2017 4:16 am

Re: Sheet protection in Calc

Post by DBGarfield »

Thank you; this works fine.
OOoV3.3 OSVista
Post Reply