Ask Your Question

Macro to password protect sheet [closed]

asked 2013-11-22 21:19:19 +0100

tcs3043 gravatar image

updated 2018-06-13 14:26:24 +0100

Lupp gravatar image

I'm trying to completely convert from Lotus 1-2-3 to Libreoffice Calc. I've run into a snag. In Lotus 1-2-3 a script can be recorded to unlock a password protected sheet, make changes, then lock the sheet with a password. In Ubuntu 12.04, Libreoffice recorded the following maco. The problem is it ends with the dialog box for setting the password. The record feature won't record the password, and press OK. If anyone can help, it would be appreciated.

sub ProtectSheet
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("")

rem ----------------------------------------------------------------------
dim args1(0) as new
args1(0).Name = "Protect"
args1(0).Value = true

dispatcher.executeDispatch(document, ".uno:Protect", "", 0, args1())

end sub
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Alex Kemp
close date 2015-11-16 00:17:24.717271

1 Answer

Sort by » oldest newest most voted

answered 2013-12-04 15:22:37 +0100

Try this ThisComponent.CurrentController.ActiveSheet.Protect "password"

ThisComponent.CurrentController.ActiveSheet.Unprotect "password"

or ThisComponent.Sheets.GetByName("Sheet1").Protect "password"

edit flag offensive delete link more

Question Tools



Asked: 2013-11-22 21:19:19 +0100

Seen: 1,477 times

Last updated: Jun 13 '18