Ask Your Question
0

Macro to password protect sheet [closed]

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

tcs3043 gravatar image

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

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 3.5.7.2 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("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
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
0

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

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

2 followers

Stats

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

Seen: 1,314 times

Last updated: Jun 13