c# Word COMException (0x800A11FD) when adding a new field to document RRS feed

  • Question

  • I want to add a new field to the Fields list in document. I am calling Doc.Unprotect("secret") to be able to add the new field because the selected fieldText is in a protected document. When the Doc.Fields.Add method is called I get the undefined COMException below.

    Does anybody know why this is happening?


    Doc.SetDocProperty(fieldKey, fieldText);

    W.Field field = Doc.Fields.Add(app.Selection.Range, W.WdFieldType.wdFieldDocProperty, fieldKey, true);


    System.Runtime.InteropServices.COMException (0x800A11FD): Dieser Befehl ist nicht verfügbar.(=Command not available)
       bei Microsoft.Office.Interop.Word.Fields.Add(Range Range, Object& Type, Object& Text, Object& PreserveFormatting)

    • Edited by dermaga Thursday, March 7, 2019 11:52 AM
    • Moved by KareninstructorMVP Thursday, March 7, 2019 1:35 PM Moved from forum
    Thursday, March 7, 2019 11:50 AM

All replies

  • Hello,

    This is not a VB.NET issue so for better visibility I'm moving your question to the Word for Developers forum.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    profile for Karen Payne on Stack Exchange

    Thursday, March 7, 2019 1:35 PM
  • What kind of protection are you using, and what is being selected before you run your code?

    For example, if you are protecting for forms and the selection is in a plain text content control, you will see that kind of error because you can't insert a field into that type of control. (You would probaby see it if the control was locked for editing etc. too, but I haven't checked)

    Peter Jamieson

    Friday, March 15, 2019 1:41 PM