PROTECT OOCALC BEING CHANGED

Hi All,

I print report to OOCalc.

I want to protect its file from being changed manually by user.

How could I do it ?

Thank you.
LVL 1
emi_sastraAsked:
Who is Participating?
 
ltlbearand3Connect With a Mentor Commented:
emi_sastra,

Here is some sample .net code that will create a calc document and save it in a protected status.

-Bear
' Create your Calc Document
        Dim objServiceManager As Object = CreateObject("com.sun.star.ServiceManager")
        Dim objOODesktop As Object = objServiceManager.createInstance("com.sun.star.frame.Desktop")
        Dim arg(-1) As Object
        Dim objCalc As Object = objOODesktop.LoadComponentFromUrl("private:factory/scalc", "_blank", 0, arg)
        Dim objSheet As Object = objCalc.Sheets.getByIndex(0)

        ' Put Data in a Cell
        Dim oCell As Object = objSheet.getCellRangeByName("A1")
        oCell.setString("This is my Data")

        ' First you have to protect the sheet with a password
        objSheet.Protect("testpass")
        ' Now Protect the Document with a password
        objCalc.Protect("testpass")

        ' Save the File
        objCalc.storetoURL("file:///C:/vb_ooo_test.ods", arg)
        objCalc.Close(False)

Open in new window

0
 
SStoryCommented:
Print it as a PDF
0
 
SStoryCommented:
Or set a password on the document. Or change user permissions for that document to read only from the operating system.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
emi_sastraAuthor Commented:
Hi All,

I still want to use (print) oocalc and I have no idea how to protect it using code after I finish printing it.

Thank you.
0
 
SStoryCommented:
That is a great post about setting the password and it would be protected even if you email it.

If you just need to protect it locally--on your network in a certain folder, another way would be to change the file's permission so that other users only have read and execute privileges on that file:

http://msdn.microsoft.com/en-us/magazine/cc163832.aspx

Of course if it is a spreadsheet and  you want to protect part from changes and the rest be changeable then the above is better by far.
0
 
emi_sastraAuthor Commented:
Hi Bear,

It works.

Thank you very much for your help.
0
 
emi_sastraAuthor Commented:
Hi SStory,

Thank you for your link.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.