我们正在运行 Office 2016 16.0.6741.2063(延迟 channel ),Office 365 API 的分配工作正常(有关使用 docx 插入等的一些问题,但 XML 没问题)
但是这段代码总是转到“blockUI 和警告”(如果我去掉(而不是)“!”,那么就可以了,所以在代码的其余部分中不是错误)。
任何形状或形式的“WordApi”都会失败(1.2、无版本、1、0.1 - 我已经尝试了所有这些!) 根据规范 2016 应该支持这个,但延迟 channel 似乎不支持?
关于如何运行此命令的任何想法(或在 JavaScript 中查找 Office 版本的任何其他技巧)
一些团队使用的是 Office 15..n 版本,我试图用它来提醒他们升级到 16..n 以减轻支持负担!
Office.initialize = function (reason) {
$(document).ready(function () {
if (! Office.context.requirements.isSetSupported('WordApi', 1.1)){
$.blockUI({message: "This Add-In only works with versions of Office 365 greater than 16, please ring the help doesk to get your version upgraded <br/><a href='https://www.office.com/1?auth=2&home=1&from=ShellLogo'><u>Or click here for Office 365</u></a>"});
}
else {
// If setSelectedDataAsync method is supported by the host application
// the UI buttons are hooked up to call the method else the buttons are removed
if (Office.context.document.setSelectedDataAsync) {
ExecuteOrDelayUntilScriptLoaded(addDocsAsYouGo, "sp.js");
ExecuteOrDelayUntilScriptLoaded(addDocsAsYouGoDefr, "sp.js");
if(!siteInitialised){
initialiseSharePointConnection();
}
if (!pathInitiliased){
clientContext.executeQueryAsync(function () {
filePath = oWebsite.get_serverRelativeUrl() + "/Shared Documents/addin/ContentDOCX/";
pathInitiliased = true;
});
}
}
}
});
};
最佳答案
所有版本的支持外接程序的客户端都支持此功能(即 2013 年、2016 年、Mac、在线版等)。您必须同意,这将是相当讽刺的(和第 22 条军规)要求您知道您所在的客户端,以便查询 API,该 API 将[有效地]告诉您您所在的客户端。
如果您没有看到此功能,请检查您正在使用的 Office.js 版本。该 API 的添加方式可追溯地使其适用于 Office 2013(未附带此 API),但您必须使用最新(或接近)版本的 Office.js。引用 CDN 将是保证这一点的最佳方式。
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/Office.js" type="text/javascript"></script>
关于javascript - 哪些版本的 Office 2016 支持 Office.context.reqirements.isSetSupported()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39142442/