none
Lock particular section of word document using c# RRS feed

  • Question

  • I want to lock particular section of word document using c#. Here I want to lock down "Attachments" cell.

    enter image description here

    Any help would be greatly appreciated.

    Wednesday, October 30, 2013 9:40 PM

Answers

  • Hi,

    I think you want to protect the particular “Attachments” cell of a table in a Word document using C#.

    AFAK, we cannot protect a cell in a table. We could protect documents and parts of documents. But the range to be protected cannot be a cell range in a table.

    For a work around, you could edit the value of the cell as below and selected the content of it manually. Then the code could be ran to set the content locked by adding a content control of the range. The ContentControl.LockContentControl Property could avoid the content control to be deleted or changed, so that the text in the control content cannot be edited or deleted.

    WordApp is the Word application.
    Word.Range rng = WordApp.Selection.Range;
    Word.ContentControl cc = rng.ContentControls.Add(Word.WdContentControlType.wdContentControlGroup);
    cc.LockContentControl = true;
    cc.LockContents = true;

    Signature                                                                                                      Data

    COPY:

    ATTACHMENTS:­­­­­__________________________

    Saturday, November 2, 2013 3:17 PM