Method SetDocumentProtection
SetDocumentProtection(WordDocument, DocumentPosition, Action<DocumentProtection>)
Changes the document's protection settings as one undoable edit. change is given a copy of
the settings as they are and changes it; the copy then takes the settings' place, and undo puts the settings
back exactly as they were, password material included. No paragraph changes: the layout is not affected.
public static DocumentEdit SetDocumentProtection(this WordDocument document, DocumentPosition at, Action<DocumentProtection> change)
Parameters
documentWordDocumentThe document.
atDocumentPositionA position in the document (where the edit's caret stays).
changeAction<DocumentProtection>Changes the copy of the settings.
Returns
- DocumentEdit
The edit (empty when
changechanged nothing).
Remarks
The settings are modelled, not enforced: this records what the document asks of a program that opens it.
DocWright.Cryptography's DocumentProtectionHash.StartEnforcing and StopEnforcing change a
DocumentProtection the way Word's Restrict Editing does, and are what to call from
change to start or stop protection with a password.
Exceptions
- ArgumentNullException
documentorchangeis null.- ArgumentException
atis not indocument.