I am new to Open Office and to this forum so please forgive me if I violate some tenet of the group.
Under Excel, years ago, I constructed a macro in Personal.xls that would when invoked cycle through all sheets in a workbook and lock the cells in each sheet regardless of the number of sheets. It would also protect each sheet so that no cells could be changed without unlocking them. At the end of the macro it would then save that workbook.
I can't figure out how to do this under Oo's basic.
Will someone please help out here?
Thank you very much.
Protecting and locking all cells in all sheets
Protecting and locking all cells in all sheets
Open Office 4.1.1 on Windows 7
Re: Protecting and locking all cells in all sheets
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Re: Protecting and locking all cells in all sheets
an example code:
Code: Select all
Sub ProtectAllSheets
Dim oDoc, oSheets, oSheet as object
Dim i as integer
oDoc = Thiscomponent
oSheets = oDoc.sheets
For i = 0 to oSheets.Count-1
oSheet = oSheets.getByIndex(i)
oSheet.Protect("")
Next i
End Sub
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Re: Protecting and locking all cells in all sheets
Thank you very much. That code cycles through each sheet nicely and protects each sheet as advertised. In addition to that, I need a statement or two to put in just before oSheet.Protect("") that will protect (lock) all the cells in the active sheet. Can you help there?
Thanks again.
Thanks again.
Open Office 4.1.1 on Windows 7
Re: Protecting and locking all cells in all sheets
If the protection property of the cells was set in Cellstyles, then it is a simpliest case.
There is some example code in this topic for adjust cellstyles:
viewtopic.php?t=48960
You need adjust used cellstyles.
(The unused, empty cells - in a new Calc document - are set "protected" by default, you can activate this property by switching the "sheet protect" parameter.)
But, if the "Protect" property of the used cells was formatted and adjusted manually, that is athe hardest case. Then you must set cell by cell this parameter.
There is some example code in this topic for adjust cellstyles:
viewtopic.php?t=48960
You need adjust used cellstyles.
(The unused, empty cells - in a new Calc document - are set "protected" by default, you can activate this property by switching the "sheet protect" parameter.)
But, if the "Protect" property of the used cells was formatted and adjusted manually, that is athe hardest case. Then you must set cell by cell this parameter.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Re: Protecting and locking all cells in all sheets
Make the file read-only.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice