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
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.
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