How can I check the password of this active sheet ?
I think it is impossible for it is the security reason.
Now I use:
REM ***** BASIC *****
Option Explicit
Global sPassword As String
Sub LockActiveSheet
Dim oSheet As Object : oSheet = ThisComponent.CurrentController.ActiveSheet
sPassword = "1234"
' Lock active sheet '
oSheet.Protect(sPassword)
End Sub
Sub CheckCorrectPassword
Dim oSheet As Object : oSheet = ThisComponent.CurrentController.ActiveSheet
oSheet.UnProtect(sPassword)
oSheet.getCellByPosition(0, 0).setString("X")
If oSheet.getCellByPosition(0, 0).String = "X" Then
MsgBox "Password is correct.", , ""
oSheet.Protect(sPassword)
Else
MsgBox "Password is not correct.", , ""
End If
End Sub
In the example, I have to interfere a cell in the active sheet.
Are there any ways to make it shorter and without touching even a cell ?