“You are not allowed to edit this selection because it is protected.” but only since Office 2013?

后端 未结 8 1630
我寻月下人不归
我寻月下人不归 2021-02-19 20:07

We\'ve had these few lines of code running happily in our applications for several years (and in several versions of Office, 2003, 2007, 2010 etc). Purpose is to perform a kind

相关标签:
8条回答
  • 2021-02-19 20:49

    In my case, this error was caused by the presence of content controls with .LockContentControl == true.

    To work around this issue, I built an IEnumerable<ContentControl> of the content controls with this property set to true, and set .LockContentControl = false. Now I can .InsertColumnsRight() without a problem. Then I restore the .LockContentControl = true for all content controls in my collection.

    0 讨论(0)
  • 2021-02-19 20:54

    For me, the issue was similar to Tim Dols answer, but I needed to unlock the content of the content control., which is the LockContents property: mycontentcontrol.LockContents = False

    For @CrazyIvan1974, the problem with that solution is that Add creates a new document. if you point at an existing document when using Add, it doesn't load the document, it creates a new document using the original as a template. That can disconnect templates and add-ins, really messing you up if you save over the original

    0 讨论(0)
提交回复
热议问题