|
Protect word
document and set the read only property for MS Word |
Protect Document is a very
helpful tool to help you keep your file the way you left it.
Edraw Office Viewer Component can protect word and excel
document from modification by the end users. Only call the
ProtectDoc method in the DocumentOpened event.
boolean ProtectDoc(long
ProtectType, [in, optional] VARIANT Password);
Helps to protect the specified
document from changes. When a document is protected, users
can make only limited changes, such as adding annotations,
making revisions, or completing a form.
ProtectType: The protection type for the specified document.
WdProtectionType.
Password: Optional Object. The password required to remove
protection from the specified document.
For Excel:
typedef enum XlProtectType
{
XlProtectTypeNormal = 0x00000001,
XlProtectTypeWindow = 0x00000002,
XlProtectTypeStruct = 0x00000004,
XlProtectTypeDrawingObjects = 0x00000010,
XlProtectTypeContents = 0x00000020,
XlProtectTypeScenarios = 0x00000040,
XlProtectTypeUserInterfaceOnly = 0x00000080,
}XlProtectType;
Example
The following vb script shows how to protect a document for
only revisions.
Sub ProtectDoc_Example()
EDOffice.ProtectDoc
XlProtectTypeNormal|XlProtectTypeWindow|XlProtectTypeStruct
End Sub
For Word:
enum WdProtectType
{
wdAllowOnlyRevisions = 0,
wdAllowOnlyComments = 1,
wdAllowOnlyFormFields = 2,
wdAllowOnlyReading = 3,
wdNoProtection = -1,
}WdProtectType;
Example
The following vb script shows how to protect a document for
only revisions.
Sub ProtectDoc_Example()
EDOffice.ProtectDoc 0
End Sub
The above program code is same
with the follow setting in the MS Word.
To enable Protect Document:
1. Click on Tools in the menu bar
2. Then click on Protect Document…
3. Then a window will pop-up asking you what you want to
protect your document for.
-The Tracked Changes option allows you to track every single
change that was made. It changes the color of the text to
red and gets underlined if you make any changes
-The Comments options only allows the user to put in
comments. (To insert a comment go to Insert>Comment and to
view a comment go to View>Comments)
-The Forms option only allows you to edit forms in the
document. You can’t edit anything else
4. To choose your option just click on the choice that you
want.
5. If you want a password then type in a password in the
“Password (optional):” text box. (Word will ask you the
password when you want to unlock your document!)
6. Click on OK
7. If you didn’t choose a password then Word will now
protect your document. If you did then another box will pop
up asking you to Confirm your password. Then click on OK.
Your document is now safe and protected!
If you want to unlock it then
1. Click on Tools
2. Then click on Unprotect Document
3. If you have a password then type it in the box that
appears
Note: Word will protect your document until you Unprotect
it. And the password is for one time use, the next time you
click on protect document you need to type the password
again. |
|