【问题标题】:Office.context.ui.displayDialogAsync Permission Denied errorOffice.context.ui.displayDialogAsync 权限被拒绝错误
【发布时间】:2016-12-28 18:40:33
【问题描述】:

我正在按照链接尝试 displayDialogAsync 方法, https://channel9.msdn.com/Shows/Office-Dev-Show/Office-Dev-Show-Episode-26-Using-the-Dialog-API-in-Office-Add-ins 当我从 GitHub 测试项目时,我在 Office.context.ui.displayDialogAsync 收到错误“Permission Denied error”。 这是一个简单的代码:

    function ShowDialog() {
        // Reference the Form.html file.
        var dialogUrl = 'https://' + location.host + '/Form.html';
        // Display the dialog.
        Office.context.ui.displayDialogAsync(dialogUrl, { width: 15, height: 27, requireHTTPS: true }, function (asyncResult) {
            if (asyncResult.status !== Office.AsyncResultStatus.Succeeded) {
                // TODO: Handle error.
                return;
            }

            // Get the dialog and register event handlers.
            var dialog = asyncResult.value;
            dialog.addEventHandler(Microsoft.Office.WebExtension.EventType.DialogMessageReceived, function (asyncResult) {
                if (asyncResult.type !== Microsoft.Office.WebExtension.EventType.DialogMessageReceived) {
                    // TODO: Handle unknown message.
                    return;
                }

                // Parse the message.
                var data = JSON.parse(asyncResult.message);
                showNotification('Hello #Office365Dev', data.name);

                // TODO: Do something with the data.

                // We got our data, time to close the dialog.
                dialog.close();
            });
        });
    }

感谢您的帮助。

【问题讨论】:

    标签: ms-office office-addins office-js


    【解决方案1】:

    根据提供的信息,不清楚您正在运行哪个 Office 应用、您正在运行哪个版本的 Office,也不清楚您正在加载哪个版本的 Office.js。

    对话框 API 仅在最新的即点即用 Office 365 版本(6741 之后)和最新的 Mac 版本中可用。确保您使用的是最新版本的 Office。对话框 API 并非在所有应用程序中都可用,但它应该在 Excel、Word 和 PowerPoint 的 Office.js 1.1 中正确加载。 Outlook 略有不同。 API 的 Office Online 应用版本仍在开发中。

    API 文档位于:https://github.com/OfficeDev/office-js-docs/blob/master/reference/shared/officeui.md

    【讨论】:

    • 感谢您的帮助。我用Office 2016 msi版本做了一个测试,我会尝试检查它是否在点击运行版本中可用。
    • 对于 MSI 版本,API 应该在 5 月更新之前可用。
    猜你喜欢
    • 2018-07-19
    • 1970-01-01
    • 2016-09-25
    • 2015-09-16
    • 2012-02-11
    • 2016-11-14
    • 2016-12-28
    • 2016-10-18
    • 2013-05-25
    相关资源
    最近更新 更多