We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How do a lock specific content in a word document?

I would like to replicate the functionality described here:

*Can’t take credit for this but I found this forum post from user “Mike” at

  • Display the Developer Tab on the ribbon. (Open word options, then click the check-box in the Popular section.)
  • With your template open, navigate to the Developer tab.
  • Click the Protect Document button. (You should see a sidebar.)
  • Under Editing Restrictions, click “Allow only this type of editing in the document” and set the dropdown to “No changes (Read only)”
  • Click somewhere in your template that isn’t the header/footer and hold Ctrl-A to select all.
  • Under the Exceptions part of the sidebar now displayed in Editing restrictions, click the check-box for ‘Everyone’. In other words, your entire document is read-only except for the main part in the middle, which can be edited by everyone.
  • Click the “Yes, Start Enforcing Protection” button, and set a password if you want to.

More info here:

superuser.com

Can I lock (or make uneditable) portions of a word document?

windows, microsoft-word, microsoft-office

asked by CT. on 07:38PM - 21 May 10

I have looked through these links on the Aspose site:

Free Support Forum

Section of word document read only

Is it possible to make few sections of a word document read only using ASPOSE. This message was posted using Page2Forum from WriteProtection - Aspose.Words for .NET and Java

But this does not appear to be the same functionality. Is there a way to access the functionality in Word through Aspose described in the first link?

@dalewhite,

Thanks for your inquiry. Apose.Words support to protect selected ranges. But please note that currently editable ranges are supported only at the inline-level, that is inside Paragraph, but editable range start and editable range end can be in different paragraphs. Badly formed editable range will be ignored when the document is saved. For your requirement, you can insert start and end range accordingly.

Furthermore, to protect a range in Word document EditableRangeStart class represents a start of an editable range in a Word document. EditableRangeEnd class represents an end of an editable range in a Word document. A complete editable range in a Word document consists of a EditableRangeStart and a matching EditableRangeEnd with the same Id. EditableRangeStart and EditableRangeEnd are just markers inside a document that specify where the editable range starts and ends.

Please check following code example. This code example sets the editable range for second paragraph of document.

Hope this helps. Please let us know if you have any more queries.

Document doc = new Document("in.docx");
doc.Protect(ProtectionType.ReadOnly);
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToParagraph(1, 0);
builder.StartEditableRange();
builder.MoveToParagraph(1, -1);
builder.EndEditableRange();
doc.Save("Out.docx");

This worked perfectly. Thanks so much!