ProtectionType enumeration

ProtectionType enumeration

Protection type for a document.

Members

NameDescription
ALLOW_ONLY_COMMENTSUser can only modify comments in the document.
ALLOW_ONLY_FORM_FIELDSUser can only enter data in the form fields in the document.
ALLOW_ONLY_REVISIONSUser can only add revision marks to the document.
READ_ONLYNo changes are allowed to the document. Available since Microsoft Word 2003.
NO_PROTECTIONThe document is not protected.

Examples

Shows how to turn off protection for a section.

doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
builder.writeln('Section 1. Hello world!')
builder.insert_break(aw.BreakType.SECTION_BREAK_NEW_PAGE)
builder.writeln('Section 2. Hello again!')
builder.write('Please enter text here: ')
builder.insert_text_input('TextInput1', aw.fields.TextFormFieldType.REGULAR, '', 'Placeholder text', 0)
# Apply write protection to every section in the document.
doc.protect(type=aw.ProtectionType.ALLOW_ONLY_FORM_FIELDS)
# Turn off write protection for the first section.
doc.sections[0].protected_for_forms = False
# In this output document, we will be able to edit the first section freely,
# and we will only be able to edit the contents of the form field in the second section.
doc.save(file_name=ARTIFACTS_DIR + 'Section.Protect.docx')

See Also