Restrict Editing
Restrict editing enables you to fully or partially protect a Word document from unintentional changes with an optional password. If the password is not specified, any user can stop enforcing the protection from the Word application.
![Location of restrict editing option in Microsoft Word application](/document/examples/1105/content/restrict-editing-protection-in-microsoft-word.png)
Note, with GemBox.Document you can modify a whole Word file even if it allows changes to just parts of a protected document.
The following example shows how you can start enforcing editing restriction protection using the DocumentProtection
class.
![Screenshot of restrict editing in Word document Protected Word file of DOCX format with editing restriction in C# and VB.NET](/document/examples/1105/content/restricted-editing-in-word-file-from-cs-vb.png)
using GemBox.Document;
class Program
{
static void Main()
{
// If using the Professional version, put your serial key below.
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
var document = DocumentModel.Load("%InputFileName%");
EditingRestrictionType restriction = %EditingRestrictionType%;
string password = "%Password%";
document.Protection.StartEnforcingProtection(restriction, password);
document.Save("Restrict Editing.docx");
}
}
Imports GemBox.Document
Module Program
Sub Main()
' If using the Professional version, put your serial key below.
ComponentInfo.SetLicense("FREE-LIMITED-KEY")
Dim document = DocumentModel.Load("%InputFileName%")
Dim restriction As EditingRestrictionType = %EditingRestrictionType%
Dim password As String = "%Password%"
document.Protection.StartEnforcingProtection(restriction, password)
document.Save("Restrict Editing.docx")
End Sub
End Module