Unable to delete contentControl from a particular document using Word Online Addin

Bill King 65 Reputation points
2023-05-26T03:19:38.27+00:00

As demonstrated by a simple gist I can add and remove a ContentControl to the body of my word documents. Sometimes I am unable to remove the content control when using the Word online version for particular word documents (that have probably been corrupted by my addin)

Here is a problem file

If you load the Scriptlab addin from the gist you will see that trying to remmove the contentControl throws the error:


{
    "stack": "RichApi.Error: The action isn’t supported by Word in a browser. Check the OfficeExtension.Error.debugInfo for more information.\n    at new n (https://appsforoffice.microsoft.com/lib/1/hosted/word-web-16.00.js:25:330439)\n    at o.processRequestExecutorResponseMessage (https://appsforoffice.microsoft.com/lib/1/hosted/word-web-16.00.js:25:394605)\n    at https://appsforoffice.microsoft.com/lib/1/hosted/word-web-16.00.js:25:392668",
    "message": "The action isn’t supported by Word in a browser. Check the OfficeExtension.Error.debugInfo for more information.",
    "name": "RichApi.Error",
    "code": "NotAllowed",
    "traceMessages": [],
    "innerError": null,
    "debugInfo": {
        "code": "NotAllowed",
        "message": "The action isn’t supported by Word in a browser. Check the OfficeExtension.Error.debugInfo for more information.",
        "errorLocation": "ContentControl.cannotDelete",
        "statement": "v.cannotDelete = ...;",
        "surroundingStatements": [
            "var v = context.root._getObjectByReferenceId(\"{9d36a482-7eba-48fb-8ed6-75f77e0e9afd}{52}\");",
            "// >>>>>",
            "v.cannotDelete = ...;",
            "// <<<<<",
            "v.cannotEdit = ...;",
            "v.delete(...);"
        ],
        "fullStatements": [
            "Please enable config.extendedErrorLogging to see full statements."
        ]
    },
    "httpStatusCode": 500
}

Is there anyway to fix this file so that Word Online can work with this document?

Word
Word
A family of Microsoft word processing software products for creating web, email, and print documents.
749 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
937 questions
0 comments No comments
{count} vote