2

I'm trying to select content control through js select() function - docs - but I'm always getting Access Denied error:

Error: 
{
    "name": "OfficeExtension.Error",
    "code": "AccessDenied",
    "message": "AccessDenied",
    "traceMessages": [],
    "debugInfo": 
    {
        "errorLocation":"ContentControl.select"
    },
    "stack":"AccessDenied: AccessDenied\n   at Anonymous function (https://appsforoffice.microsoft.com/lib/1.1/hosted/word-win32-16.00.js:19:150094)\n   at yi (https://appsforoffice.microsoft.com/lib/1.1/hosted/word-win32-16.00.js:19:163912)\n   at st (https://appsforoffice.microsoft.com/lib/1.1/hosted/word-win32-16.00.js:19:163999)\n   at d (https://appsforoffice.microsoft.com/lib/1.1/hosted/word-win32-16.00.js:19:163819)\n   at c (https://appsforoffice.microsoft.com/lib/1.1/hosted/word-win32-16.00.js:19:162405)"
}
Debug info: {"errorLocation":"ContentControl.select"}

Also body.getHtml() and body.getOoxml() returns the same Access Denied error.

Code snippet:

// Run a batch operation against the Word object model.
Word.run(function (context) {

    // Create a proxy object for the content controls collection.
    var contentControls = context.document.contentControls;

    // Queue a command to load the id property for all of the content controls. 
    context.load(contentControls, 'id');

    // Synchronize the document state by executing the queued-up commands, 
    // and return a promise to indicate task completion.
    return context.sync().then(function () {
        if (contentControls.items.length === 0) {
            console.log('No content control found.');
        }
        else {
            // Queue a command to select the first content control.
            contentControls.items[0].select();

            // Synchronize the document state by executing the queued-up commands, 
            // and return a promise to indicate task completion.
            return context.sync()
                .then(function () {
                    console.log('Selected the first content control.');
            });
        }
    });  
})
.catch(function (error) {
    console.log('Error: ' + JSON.stringify(error));
    if (error instanceof OfficeExtension.Error) {
        console.log('Debug info: ' + JSON.stringify(error.debugInfo));
    }
});

Firstly I thought it might be something wrong with my code but I've also tried snipper-explorer and the same problem appeared. (tried hosting manifest & app both locally and over the Internet)

Someone reported the same issue in github - github.com/OfficeDev/office-js-snippet-explorer/issues/13 - but solution with changing IE security options didn't solve my case.

My Word version - 16.0.4266.1001

4

1 に答える 1