0
我写了调试puposes下面的代码:为什么Office.EventType.DocumentSelectionChanged不一致速度慢?
(function() {
"use strict";
// The initialize function is run each time the page is loaded.
Office.initialize = function (reason) {
$(document).ready(function() {
// Use this to check whether the API is supported in the Word client.
if (Office.context.requirements.isSetSupported('WordApi', 1.1)) {
// Do something that is only available via the new APIs
Office.context.document.addHandlerAsync(Office.EventType.DocumentSelectionChanged, onSelectionChanged);
}
else {
// Just letting you know that this code will not work with your version of Word.
$('#status').html('This code requires WordApi 1.1 or greater.');
}
});
};
var c = 1;
function onSelectionChanged(eventArgs) {
c++;
$('#status').html('onSelectionChanged() call '+c+);
}
})();
此代码仅有时反应的变化。有时候会很慢。有时候(我猜如果它太慢了,并且它们之间有多重变化,它会在一段时间后不能识别它们并打印onSelectionChanged() call 4
,即使已经发生了很多更改 其他时候,如果我关闭了Word,并重新打开它,它只是作为一种魅力,然后我关闭它,再次打开它,并再次失败 - 它是完全不一致的,因此这个功能是不可用的
我在不同的机器上测试过,不同版本的Windows和它的occures系统的利用率的影响无关。
任何想法?
恐怕我不能分享这份文件。我试图用其他许多文件重现问题并失败。但是,我的整个加载项是围绕此文档构建的。 该文档具有> 200页,主要包含带文本的表格。 –
你在做什么? –
我的问题是16.0.4549.1000以及Word版本1706(Build 8229.2086)。现在我建立了一个解决方法,避免了事件。 –