[Libreoffice-bugs] [Bug 140485] Password does not get set to Protect Sheet when added through LibreOffice BASIC

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Thu Feb 18 13:28:30 UTC 2021


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

--- Comment #1 from Uwe Auer <uwe at franke-auer.de> ---
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20210218/be046d74/attachment.htm>


More information about the Libreoffice-bugs mailing list