尝试获取ScreenUpdating属性时AccessViolationException [英] AccessViolationException when trying to get ScreenUpdating property

查看:67
本文介绍了尝试获取ScreenUpdating属性时AccessViolationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发Excel插件,上周我们的一位客户遇到了我们的插件问题。他试图使用将工作表从模板文件复制到当前工作簿的函数。在我们开始复制之前,我们禁用计算
和屏幕更新。但是获取ScreenUpdating属性的当前值会导致AccessViolationException。以下是用户发送给我们的屏幕截图:

We are developing an Excel addin and last week one of our customers experienced an issue with our addin. He tried to use a function that copies a worksheet from a template file to the current workbook. Before we start copying we disable the calculations and screen updating. But getting the current value of the ScreenUpdating property causes an AccessViolationException. Here is a screenshot that the users sent us:

DisableScreenUpdating中的代码是:

The code in DisableScreenUpdating is:

try {
   screenUpdating = Application.ScreenUpdating;
   Application.ScreenUpdating = false;
   }
catch (Exception exception) {
   Debug.Write(exception.Message);
}

我们保存属性的当前值,然后禁用它。但是当访问当前值时,异常就会发生。

We save the current value of the property and then disable it. But when accessing the current value the exception happens.

可能导致这种情况的原因是什么?我们也在其他位置使用完全相同的逻辑。这是第一步,然后我们将工作表复制到当前工作簿,然后恢复已保存的状态。

What could be causing this? We are using exact same logic on other locations as well. Here it is the first step, then we copy a worksheet to the current workbook and then restore the saved state.




推荐答案

Hello Mitja,

Hello Mitja,

根据屏幕截图,您使用的是Add-in Express,而不是VSTO。所以,我建议先与他们联系。

Based on the screenshot you use Add-in Express, not VSTO. So, I'd suggest contacting them first.


这篇关于尝试获取ScreenUpdating属性时AccessViolationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆