https://bugs.documentfoundation.org/show_bug.cgi?id=140485

--- Comment #1 from Uwe Auer <[email protected]> ---
The problem is with

> If IsMissing(pPassword) Then pPassword = "SomePassword" 

which does not set the password pPassword to "SomePassword". Runtime function
"IsMissing" tests if a function is called with an _optional_ parameter and
function "LockSheet" has no optional parameter called pPassword. Therefore
pPassword stays empty and protection is activated with an "empty" password.
Change the code to something like:

>Sub LockThisSheet
>    LockSheet("Sheet1")
>End Sub
>
>Function LockSheet(passedSheetname, optional pPassword ) 
>
>    Dim oDoc        As Object : oDoc    = ThisComponent
>    Dim oSheet      As Object : oSheet  = 
> oDoc.Sheets.getByName(passedSheetname)
>    
>    If IsMissing(pPassword) Then pPassword = "SomePassword" 
>    oSheet.UnProtect(pPassword)
>    oSheet.Protect(pPassword)
>
>End Function

>From my perspective not a bug

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to