title: How would I extract editors allowed to edit a Word document for use in a SharePoint Workflow?
body: <p>I'm trying to determine the best way to programmatically extract the "Editors" from a Microsoft Word document (docx) - specifically, the list of names (or emails / domain user names) that appear in the list when you add users through the "Review" tab-> "Protect" section, "Restrict Editing" option -> "2. Editing restrictions" section -> "Individuals" list box. If this might somehow be achieved without code, I'm mentioning that SharePoint will be in use to extract this info during a workflow.</p>
  
  <p>I believe I would be able to do it by unzipping the file and searching for the "w:permStart" nodes in the document.xml file, I hesitate to resort to such hacking for the possibility that it could break at some point should Microsoft decide to change things.</p>
  
  <p>The Office API seems to offer a possibility (<a href="http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.editor(v=office.14).aspx" rel="nofollow noreferrer">Editor Interface</a>) but I can't test that right now and I'm not positive it's even at the right level of the api, as it's an interface and not an actual property of a document object or similar.</p>
  
  <hr>
  
  <h2>EDIT</h2>
  
  <p>The Word 2010 UI lists the names I want to extract under the <code>Review</code> tab, in the <code>Protect</code> area of the ribbon, through the <code>Restrict Editing</code> button (or the <code>Protect Document</code> button in Word 2007), which opens the <code>Restrict Formatting and Editing</code> panel. </p>
  
  <p>In the second section section of this panel (labeled <code>2. Editing restrictions</code>), <em>if there is no box labeled <code>Individuals</code> (Underneath <code>Exceptions (optional)</code>)</em>, check the <code>Allow only this type of editing in the document</code> check box (it doesn't matter what is selected in the drop-down following that). </p>
  
  <p>This will enable adding users under the <code>Exceptions (optional)</code> section, which is done by clicking the <code>More users...</code> link to open a dialog where one types either email addresses (which connect to a Microsoft authentication server) or domain user accounts (if Word is being run on a domain system at the time) separated by a semicolon. These users will be added to a list labeled <code>Individuals</code> - this is the list I would like to extract from a word document (pictured below).</p>
  
  <p>This list is used to make "exceptions" to the general document rule specified in the drop down and will only save names that are associated with a given exception range - create a range by adding an email or name to the list, select a block of text (or the whole document), then check the checkbox next to that name to associate it with the selected range. When the document is saved, a reference to that name is added to the underlying document.xml file as the <code>w:ed</code> attribute of one or more <code>w:permStart</code> elements (one element for each range of text)</p>
  
  <p>I <em>could</em> unzip the docx file, parse the document.xml document and extract all the names in those attributes in those elements, but that is very inelegant if there is a Microsoft Word API alternate way of doing it - I would prefer going through the API as it would almost certainly be more maintainable and stable.</p>
  
  <p><img src="https://i.stack.imgur.com/zmSSn.png" alt="Review-&gt;Protect-&gt;Restrict Editing-&gt;Restrictions-&gt;Individuals"></p>