none
Protecectio part of word file RRS feed

Answers

  • You will need to insert Section Breaks to separate the file into the parts that can be edited and those that cannot and then protect the document for filling in forms.

    -- Hope this helps.

    Doug Robbins - Word MVP,
    dkr[atsymbol]mvps[dot]org
    Posted via the Community Bridge

    "Mukund Khalatkar" wrote in message news:42b651ae-79f6-4935-a73a-741c0b11298e@communitybridge.codeplex.com...

    I want to protect some parts of word file so which can not be edited by others


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
    Friday, November 19, 2010 9:09 AM
  • Hi Mukund,

    Besides what Doug suggested, here is also a code snippet for that:
    this.Sections[1].ProtectedForForms = false;
    this.Sections[2].ProtectedForForms = true;
    this.Sections[3].ProtectedForForms = false;
    object noReset = true;
    object password = "password";
    this.Protect(Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyFormFields, ref noReset, ref password, ref missing, ref missing);
    
    

    Also another type of protection is the "Read-Only" type.
    You can see both by going to the Developer tab, then clicking "Protect Document" and choosing "Restrict formatting and editing". That displays a task pane where the type of document protection can be set. Test these two types of protection to see if they do what you want. Both types will limit editing in a document to a certain extent, but differently. Common to both types of protection is that the user will not be able to use the graphics layer (manipulate members of the Shapes collection; InlineShapes will still work). With Forms protection, the user will not be able to work in the header/footer area. If you decide this type of protection is acceptable, you can record setting the protection in a macro to get the basic syntax for your code.

    An alternative would be to insert a Content Control at the place for the new text and insert the text. Set the content control to be locked and non-deletable. This approach provides the most flexibility in otherwise editing the document and better security. There is no option for password locking/unlocking, but you can build that into your application.  Hope they will be helpful!

    Best Regards,
    Amy Li


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Monday, November 22, 2010 3:07 AM
    Moderator

All replies

  • You will need to insert Section Breaks to separate the file into the parts that can be edited and those that cannot and then protect the document for filling in forms.

    -- Hope this helps.

    Doug Robbins - Word MVP,
    dkr[atsymbol]mvps[dot]org
    Posted via the Community Bridge

    "Mukund Khalatkar" wrote in message news:42b651ae-79f6-4935-a73a-741c0b11298e@communitybridge.codeplex.com...

    I want to protect some parts of word file so which can not be edited by others


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
    Friday, November 19, 2010 9:09 AM
  • Hi Mukund,

    Besides what Doug suggested, here is also a code snippet for that:
    this.Sections[1].ProtectedForForms = false;
    this.Sections[2].ProtectedForForms = true;
    this.Sections[3].ProtectedForForms = false;
    object noReset = true;
    object password = "password";
    this.Protect(Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyFormFields, ref noReset, ref password, ref missing, ref missing);
    
    

    Also another type of protection is the "Read-Only" type.
    You can see both by going to the Developer tab, then clicking "Protect Document" and choosing "Restrict formatting and editing". That displays a task pane where the type of document protection can be set. Test these two types of protection to see if they do what you want. Both types will limit editing in a document to a certain extent, but differently. Common to both types of protection is that the user will not be able to use the graphics layer (manipulate members of the Shapes collection; InlineShapes will still work). With Forms protection, the user will not be able to work in the header/footer area. If you decide this type of protection is acceptable, you can record setting the protection in a macro to get the basic syntax for your code.

    An alternative would be to insert a Content Control at the place for the new text and insert the text. Set the content control to be locked and non-deletable. This approach provides the most flexibility in otherwise editing the document and better security. There is no option for password locking/unlocking, but you can build that into your application.  Hope they will be helpful!

    Best Regards,
    Amy Li


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Monday, November 22, 2010 3:07 AM
    Moderator