How to prevent edit

S

Susan

Hi guys

Is it possible to programmatically open a word document which can not be edited (i.e., in some kind of a view only mode)? wordApp.Documents.Open with ReadOnly = true, does not prevent editing (just saving). No IRM please, it is Word 2002

Many thanks
Susan
 
C

Chad DeMeyer

Susan, try this:

Assign the document object you open to a variable using a set statement
(e.g., Set oDoc = wordApp.Documents.Open ...).

For Each oSec in oDoc.Sections
oSec.ProtectedForForms = -1 '-1 = True
Next oSec
oDoc.Protect 2, -1, password '2 = wdAllowOnlyFormFields, substitute a
valid password string for "password"

The above code will in effect make the document view only AND prevent the
user from removing the protection without knowing the password. This is
assuming there are no formfields in the document. If that were the case,
you would also need to loop through all the formfields in the document and
set their Enabled property to 0 (False).

Hope this helps
Regards,
Chad

Susan said:
Hi guys!

Is it possible to programmatically open a word document which can not be
edited (i.e., in some kind of a view only mode)? wordApp.Documents.Open with
ReadOnly = true, does not prevent editing (just saving). No IRM please, it
is Word 2002.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top