[Solved] Turn on/off cell protection using BASIC macro
Posted: Fri Sep 24, 2010 10:54 pm
Hello,
Have some troubles with Calc regarding "data safety".
I think the solution will be helpfull to many of Calc users.
I'll keep it short.
I use OpenOffice 3.2.1 on WinXP/WinVista/Win7/Ubuntu 10.04.
1. A calc document contains 1 sheet. The doc and the sheet are password protected.
2. The user opens the doc and types in the password.
3. Initially all cells in the sheet are protected, so the user can't make any changes unless he allows macros to be used.
4. If he does, a macro called OpenSession is invoked right after the stage 2.
NewSession macro turns off protection of all the non-empty cells within the given area.
This causes the user to have an ability to enter new data in these cells.
5. The user enters new data, saves and cloese the document or he clicks the close button („X”) of the window and agrees to store unsaved data.
6. Upon document closing another macro called CloseSession is executed. It's crucial task is to turn on protection for every cell in the sheet.
The secondary task of CloseSession macro is do some data cleaning. It means that i.e. if the user didn't filled in all the mandatory cells in a row, the whole row will be cleared from all content.
Main questions is:
Q1: How do you turn on/off protection of a given cell or cell area using a BASIC macro instruction?
My other questions:
Q2: Is it possible to protect cell's format from being changed by the user while he can modify the content of that cell at the same time?
Q3: Is there a key shortcut I can use to open a listbox that apears in selected cell after applying Menu->Data->Data verification->List?
Please help.
Thank you in advance.
Cheers,
Darius/Poland
Have some troubles with Calc regarding "data safety".
I think the solution will be helpfull to many of Calc users.
I'll keep it short.
I use OpenOffice 3.2.1 on WinXP/WinVista/Win7/Ubuntu 10.04.
1. A calc document contains 1 sheet. The doc and the sheet are password protected.
2. The user opens the doc and types in the password.
3. Initially all cells in the sheet are protected, so the user can't make any changes unless he allows macros to be used.
4. If he does, a macro called OpenSession is invoked right after the stage 2.
NewSession macro turns off protection of all the non-empty cells within the given area.
This causes the user to have an ability to enter new data in these cells.
5. The user enters new data, saves and cloese the document or he clicks the close button („X”) of the window and agrees to store unsaved data.
6. Upon document closing another macro called CloseSession is executed. It's crucial task is to turn on protection for every cell in the sheet.
The secondary task of CloseSession macro is do some data cleaning. It means that i.e. if the user didn't filled in all the mandatory cells in a row, the whole row will be cleared from all content.
Main questions is:
Q1: How do you turn on/off protection of a given cell or cell area using a BASIC macro instruction?
My other questions:
Q2: Is it possible to protect cell's format from being changed by the user while he can modify the content of that cell at the same time?
Q3: Is there a key shortcut I can use to open a listbox that apears in selected cell after applying Menu->Data->Data verification->List?
Please help.
Thank you in advance.
Cheers,
Darius/Poland