none
Getting error "This method or property is not available because the document is locked for editing." RRS feed

  • Question

  • Hi All

    I am trying to get the style of range(tbl.Cell(1, 3).Range). everything works fine but when the document is in read only mode it gives me the "This method or property is not available because the document is locked for editing."

    I am using the returned style for the comparison purpose . Please see the below code sippet

      sty = (Style)range.get_Style();

                               if (sty.NameLocal == Constants.RightFooterStyle)
                               {
                                   returnStatus = true;
                               }

     

     

    Thanks

    Abhi

    Monday, January 30, 2012 8:21 AM

All replies

  • Hi Abhi

    Then you'd have to unproctect the document, preform the operation, then re-instate the protection.


    Cindy Meister, VSTO/Word MVP
    Monday, January 30, 2012 9:32 AM
    Moderator
  • Hi Cindy

    Thanks for your reply can you please tell me how to unprotect the document .

    Monday, January 30, 2012 10:46 AM
  • Document.Unprotect
    Cindy Meister, VSTO/Word MVP
    • Marked as answer by abhi_engr Wednesday, February 1, 2012 11:32 AM
    • Unmarked as answer by abhi_engr Tuesday, February 7, 2012 11:12 AM
    Monday, January 30, 2012 1:05 PM
    Moderator
  • Document.UnProtect raise an exception so I tried using doc.RemoveLockedStyles(); and it worked for me

     


    Regards Abhi
    • Marked as answer by abhi_engr Thursday, February 2, 2012 8:00 AM
    • Unmarked as answer by abhi_engr Tuesday, February 7, 2012 11:12 AM
    Thursday, February 2, 2012 7:59 AM
  • Hi Cindy

    I would like to know can we make document editable through code if it is in Read-Only Mode

    Thanks


    Regards Abhi

    Tuesday, February 7, 2012 8:53 AM