none
Editable/NonEditable sections of Word Document RRS feed

  • Question

  • Hi,

    When I am building a Word Document Programmatically, is there any way of making certain paragraphs "Editable" while preventing updatings to other paras?

    Thanks,

    VK

     

     

    Tuesday, July 12, 2011 4:18 AM

Answers

  • Word 2007/2010


    Lupu presents you with one possibility.

    another would be to use "editing protection". To see that in the UI, go to the Developer tab, Protect Document, Restrict Formatting and Editing.  In Step 2, activate the checkbox and make sure "No changes" is set in the dropdown.

    Select each range where you want to allow editing, then click the checkbox in Step 3.

    When you're ready, click "Yes, start enforcing protection".

    This can be augmented with Information Rights Management (IRM) if you require fine granularity. In the object model, these things combine the Editors object and Protect method.

    This approach is more restrictive in what the user is allowed to do in the document than the one Lupu suggests.


    Cindy Meister, VSTO/Word MVP
    • Proposed as answer by Bruce Song Wednesday, July 20, 2011 2:59 AM
    • Marked as answer by Bruce Song Thursday, July 21, 2011 7:38 AM
    Wednesday, July 13, 2011 10:14 AM
    Moderator

All replies

  • Which version of Word?
    Cindy Meister, VSTO/Word MVP
    Tuesday, July 12, 2011 6:52 AM
    Moderator
  • Word 2007/2010
    Tuesday, July 12, 2011 9:51 AM
  • Hello,

     

    You could use ContentControls for this operation. You could take the paragraphs at the opening of the document, analyze each and decide via code (or some other method) if it is to become read-only or not. If it is to be read-only, insert a RichContentControl and copy the whole text inside the contentControl. Then you can LockContents=true; and LockContentControls=true (so it cannot be deleted anymore).At DocumentBeforeClose you could remove all the ContentControls added.

     

    This can be done via Add-In or ar document level also.

     

    Best regards,

    Silviu.


    http://www.rosoftlab.net/
    Wednesday, July 13, 2011 5:59 AM
  • Word 2007/2010


    Lupu presents you with one possibility.

    another would be to use "editing protection". To see that in the UI, go to the Developer tab, Protect Document, Restrict Formatting and Editing.  In Step 2, activate the checkbox and make sure "No changes" is set in the dropdown.

    Select each range where you want to allow editing, then click the checkbox in Step 3.

    When you're ready, click "Yes, start enforcing protection".

    This can be augmented with Information Rights Management (IRM) if you require fine granularity. In the object model, these things combine the Editors object and Protect method.

    This approach is more restrictive in what the user is allowed to do in the document than the one Lupu suggests.


    Cindy Meister, VSTO/Word MVP
    • Proposed as answer by Bruce Song Wednesday, July 20, 2011 2:59 AM
    • Marked as answer by Bruce Song Thursday, July 21, 2011 7:38 AM
    Wednesday, July 13, 2011 10:14 AM
    Moderator
  • Thanks Lupu and Cindy for your replies.

    Cindy,

    Whatever you've suggested, can I achieve it programmatically?

     

    Thanks,

    Vishal

     

    Wednesday, July 13, 2011 7:13 PM
  • Hi Vishal

    <<Whatever you've suggested, can I achieve it programmatically?>>

    Both approaches can be achieved programmatically. I started with the description in the UI so that you can test both approaches to see which better meets your needs. Both are valid, "better" depends very much on what you require.

    As to the one I suggest, I repeat what I said in my previous message: "In the object model, these things combine the Editors object and Protect method." You can search those terms in the object model help, and they'll also show up if you record steps in the UI with a macro.


    Cindy Meister, VSTO/Word MVP
    Thursday, July 14, 2011 9:57 AM
    Moderator
  • Thanks Cindy for your suggestions
    Thursday, July 14, 2011 7:38 PM