Hi, I am new here. I have started using OO recently. I have used the macro recording to record the following macro and added the password statement (highlighted in red) , but it doesn't work!
Can anyone please help me? Millions thanks!
rem ----------------------------------------------------------------------
dim args5(4) as new com.sun.star.beans.PropertyValue
args5(0).Name = "Protection.Locked"
args5(0).Value = true
args5(1).Name = "Protection.FormulasHidden"
args5(1).Value = false
args5(2).Name = "Protection.Hidden"
args5(2).Value = false
args5(3).Name = "Protection.HiddenInPrintout"
args5(3).Value = false
args5(4).Name = "Password"
args5(4).Value = "1234"
dispatcher.executeDispatch(document, ".uno:Protection", "", 0, args5())
Password Protection
Password Protection
Jennifer
Re: Password Protection
Hi Jennifer!
Macro recorder seldom gives usefull code.
Two things can be password protected, I'm not quite sure what you need.Of course both macros can be combined if you want...
Hope it helps!
Uros
Macro recorder seldom gives usefull code.
Two things can be password protected, I'm not quite sure what you need.
Code: Select all
Sub StoreWithPassword
Dim mProperties(0) As New com.sun.star.beans.PropertyValue
mProperties(0).Name = "Password"
mProperties(0).Value = "1234"
sUrl = convertToURL("file:///home//user/mydocs/document.sxc")
oDocument = ThisComponent
oDocument.storeToURL(sUrl,mProperties())
End Sub
Sub PasswordProtectedSheet
sPass = "1234"
oDocument = ThisComponent
oSheets = oDocument.Sheets
oSheet = oSheets.getByIndex(0) ' first sheet
oSheet.Protect(sPass)
' oSheet.Unprotect(sPass)
End Sub
Hope it helps!
Uros
Re: Password Protection
Hi Uros
Thank you so much! Yes, it works perfectly! BTW, what is the difference between StoreWithPassword and PasswordProtectedSheet? PasswordProtectedSheet is the one I am looking for.
Thanks! Have a great weekend!
Thank you so much! Yes, it works perfectly! BTW, what is the difference between StoreWithPassword and PasswordProtectedSheet? PasswordProtectedSheet is the one I am looking for.
Thanks! Have a great weekend!
Jennifer
Re: Password Protection
Hi Jennifer!
I'm glad I can help!
Uros
You already know what PPS macro do. SWP macro stores your document as password protected. So next time you try to open this document, you will be asked for a password before actual opening the file...jenteh wrote:BTW, what is the difference between StoreWithPassword and PasswordProtectedSheet? PasswordProtectedSheet is the one I am looking for.
I'm glad I can help!
Uros
Re: Password Protection
Oh, I see, SWP is password for saving file.
Thanks alot, Uros! I wish you & everyone in this forum a Merry Christmas & a Happy New Year 2008!
Thanks alot, Uros! I wish you & everyone in this forum a Merry Christmas & a Happy New Year 2008!
Jennifer