Page 1 of 1

protect (lock) content of MS Word document

Posted: Thu Apr 28, 2005 4:29 am
by ddragas
Hi all

Is it posible to protect (lock) (with password) content of MS Word document after creating it?

Posted: Thu Apr 28, 2005 4:54 am
by malcolmboston
restrict read/write access to the file?

Posted: Thu Apr 28, 2005 4:59 am
by ddragas
Just not to permit user to change document.

Posted: Thu Apr 28, 2005 5:03 am
by n00b Saibot
Do you want to do it through your script or directly in MS-Word :?:

In Word there is option to restrict access to read-only until a password is given. Goto Tools > Options > Save.
Set a password under Password to modify box and confirm it once again and you are done.

Posted: Thu Apr 28, 2005 5:38 am
by ddragas
I want to do it through script. To alow user to see document, but not to change it. Something like pdf file. In pdf file you can not write nothing.

Posted: Thu Apr 28, 2005 5:47 am
by n00b Saibot
That you can do using COM extension in PHP. For further detail about objects, methods etc. read MS-Word's help file. A lot of info is given there. You just have to invoke the particular command through COM.

Posted: Thu Apr 28, 2005 3:32 pm
by method_man
for a read only file you do this

Code: Select all

<html>
<body>

<?php
$f=fopen("welcome.txt","r");
?>

</body>
</html>
r Read only. File pointer at the start of the file

r+ Read/Write. File pointer at the start of the file

w Write only. Truncates the file (overwriting it). If the file doesn't exist, fopen() will try to create the file

w+ Read/Write. Truncates the file (overwriting it). If the file doesn't exist, fopen() will try to create the file

a Append. File pointer at the end of the file. If the file doesn't exist, fopen() will try to create the file

a+ Read/Append. File pointer at the end of the file. If the file doesn't exist, fopen() will try to create the file

x Create and open for write only. File pointer at the beginning of the file. If the file already exists, the fopen() call will fail and generate an error. If the file does not exist, try to create it

x+ Create and open for read/write. File pointer at the beginning of the file. If the file already exists, the fopen() call will fail and generate an error. If the file does not exist, try to create it

add the leter thing you want in the quotes next to the .txt

the "are+" and "are" are supposed to be the letter are but it doesnt let me put it because it corrects it

these are all of the different file things you can do with your text documents
hope this helps