New "editing/editing/viewing" button problems with COM Addins

Copper Contributor

It's buggy with (C#) COM Addins when documents have (password) protection.

If you unprotect the document with a COM addin, you can't change anything in the same method.


Just create a custom button in your Ribbon, then do something like this :


_Document doc = Application.ActiveDocument;
doc.Unprotect(); // This works, the document is unprotected and doc.ProtectionType is WdProtectionType.wdNoProtection.
doc.Range(0, 0).Text = "test"; // This will fail. Selection.Text = "test"; fails too


Every changes to ranges will fail with COMException 0x800a17ec "You are not allowed to edit this selection because it is protected." even if doc.ProtectionType is WdProtectionType.wdNoProtection.


0 Replies