protect (lock) content of MS Word document

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

protect (lock) content of MS Word document

Post by ddragas »

Hi all

Is it posible to protect (lock) (with password) content of MS Word document after creating it?
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

restrict read/write access to the file?
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

Post by ddragas »

Just not to permit user to change document.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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.
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

Post 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.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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.
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

Post 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
Post Reply