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

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.

Protected Word file of DOCX format with editing restriction in C# and VB.NET
Screenshot of restrict editing in Word document
Upload your file (Drag file here)
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

See also


Next steps

GemBox.Document is a .NET component that enables you to read, write, edit, convert, and print document files from your .NET applications using one simple API. How about testing it today?

Download Buy