我正在为Word编写加载项。我有Word 2016.在这种情况下,Office.context.requirements.isSetSupported('WordApi', 1.1)
应该返回true
,但它返回false
。并且Word
对象未定义。有任何想法吗?谢谢。在Windows 7单词对象在Word2016中未定义
的Microsoft Word 2016 MSO(16.0.6326.1022)32位企业
下面是我的一些代码片段:
在我html
的head
我有这样的:
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/Office.js" type="text/javascript"></script>
<script src="local/js/common.js"></script>
common.js以
开头Office.initialize = function(reason) {
console.log(Office.context.requirememts)
if (Office.context.requirements.isSetSupported('WordApi', 1.1)) {
//never gets in here
}
else {
console.log("This add-in requires Word 2016 or greater.");
}
};
的Office.context.requirememts
没有isSetSupported
功能
UPDATE: 有一两件事,我不认为是相关的,但显然它。我的负载HTML页面重定向到另一个HTML页面,似乎导致了这个问题。我之所以有重定向是因为当XML文件
<SourceLocation DefaultValue="http://localhost/wordaddin/index.html"/>
,而不是
<SourceLocation DefaultValue="C:\WordAddIn\index.html"/>
html文件的内容缓存,并没有办法(没有我发现在至少)清除此缓存。因此,无论我在index.html中做什么更改都不会完成。因此,在index.html的负载上,我做了window.location='main.html?'+datestamp
,并且做了这个诀窍,但后来我陷入了这个怪事。
下面是index.html的:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<script>
function init() {
var timestamp = new Date().valueOf();
window.location = "main.html?" + timestamp;
}
</script>
</head>
<body onload="init()">
</body>
</html>
你能分享Word版本+内部版本号吗? 你能确认这是Word 2016 for Windows吗? 请发布您的代码。您尝试过的任何参考资料或来源都会有所帮助。 –