Macro to password protect sheet

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

Try this
ThisComponent.CurrentController.ActiveSheet.Protect “password”

ThisComponent.CurrentController.ActiveSheet.Unprotect “password”

or
ThisComponent.Sheets.GetByName(“Sheet1”).Protect “password”