Skip to main content
Windward

DOCX Protection

Overview

Windward fully supports DOCX document protection (starting with version 13). However, you have to be careful how you use it combined with ForEach and If tags. You need to make sure that each protection start/end is placed once per iteration in the loop.

 

Protection is implemented using permissions. MS Office calls this "document protection," but in the DOCX file, regions are marked as permStart/permEnd. So in the DOCX all of the file is locked except the areas that have permission to allow some users to perform certain tasks.

Setting Permissions in a Tagged Template

A natural way to set permissions to edit a row in a table is to select the row and then mark it as editable.

If that row has a ForEach tag in it (usually in the first cell) this will fail. Here's an example template:

 

Name Title Salary
<start permission>[forEach][out] [out] [out]<end permission>
[end forEach]    

 

 

When the above runs, you will get the following:

Name Title Salary
<start permission>John Smith Programmer $1,234.56<end permission>
Natasha Johansen Programmer $1,234.57<end permission>

 

The Output above is exactly what you told the tags to do: start the permission, then iterate through the rows, and end the permission at the end of each row. The first row will be editable because it has a start and end permission. The subsequent rows will not because they do not have start permissions for each new row.

 

Instead you need to do set up your table as follows:

Name Title Salary
[forEach]<start permission>[out] [out] [out]<end permission>
[end forEach]    

Set the begin and end permissions just inside the ForEach loop, with the Out Tags inserted inside the start/end permissions.

Partial cells when the ForEach Loop has order='column'

When you set the permission to be all the contents of a cell, Word usually (but not always) saves it as follows:

<start permission id='0'>cell 0 contents
<start permission id='1'><end permission id='0'>cell 1 contents
<start permission id='2'><end permission id='1'>cell 2 contents

<end permission id='2'>

 

Word puts the end in the start of the next cell. And yes, they even start the next permission before ending the previous permission. The problem here with order='column' is you will then get:

<start permission id='0'>cell 0, 0 contents <start permission id='0'>cell 0, 1 contents <start permission id='0'>cell 0, 2 contents
<start permission id='1'><end permission id='0'>cell 1, 0 contents <start permission id='1'><end permission id='0'>cell 1, 1 contents <start permission id='1'><end permission id='0'>cell 1, 2 contents
<start permission id='2'><end permission id='1'>cell 2, 0 contents <start permission id='2'><end permission id='1'>cell 2, 1 contents <start permission id='2'><end permission id='1'>cell 2, 2 contents

<end permission id='2'>

 

The table above will lose most of the permissions because Word goes row major, so it goes across all row 0 looking for an end. It then has 3 starts all tying to the end in cell [1,0] and only one of them gets it. There is no way for us to adjust for this because (for the standard order in a ForEach) you want it to operate this way.

So for order='column' do not give edit permission to the entire contents of a cell. If you want everything editable, put a space at the end of the cell contents and select everything except that trailing space.

  • Was this article helpful?