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

Bill King 95 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?

Microsoft 365 and Office Development Office JavaScript API
Microsoft 365 and Office Word For business Windows
0 comments No comments
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.