Excel 2013使用多个工作簿进行屏幕更新问题 [英] Excel 2013 screenupdating issue with multiple workbooks

查看:81
本文介绍了Excel 2013使用多个工作簿进行屏幕更新问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在打开或创建新工作簿时,Excel 2013中显示了对此过程所做的一些更改。 由于焦点变化,此更改会导致与屏幕更新相关的VBA问题。 在2007/2010
如果screenupdating = false,任何打开或创建的工作簿将明显隐藏在关闭屏幕更新之前显示的任何内容之后。 在Excel 2013中,新工作簿窗口将明显与初始工作簿和任何冻结视图重叠。 
它将保持空白,但它将涵盖初始工作簿和任何已打开的表单。 此新焦点似乎也会影响为以前版本的Excel使用而创建的其他代码。 当其他工作簿
被打开或关闭时,被视为活动工作簿的内容在2013年的反应不同。  即使screenupdating = false "active"中的任何更改也是如此。工作簿将导致当前活动的工作簿显示在顶部,导致闪烁或覆盖用户表单等。 
同样在2013年,如果在打开第二个工作簿后立即打开表单,则该表单将在第二个工作簿关闭时自动关闭。在这种情况下UserForm_QueryClose  event将使CloseMode值为5. 对于CloseMode,没有
作为5的记录值,但是,VB6的UnloadMode值为5,指的是关闭表单,因为"所有者"是已关闭。 这似乎符合所描述的情况,但这在2010年没有发生。 我使用
windows 8和Excel 2013 64bit。 问一个问题;如何阻止新打开的工作簿或"活动"工作簿?工作簿显示在主工作簿和用户窗体之上?

It appears that some changes were made in Excel 2013 to the process involved when opening or creating new workbooks.  This change is causing problems with VBA that relate to screenupdating because of the changing focus.  In 2007/2010 if screenupdating = false, any workbooks opened or created will be visibly hidden behind whatever was showing prior to turning screenupdating off.  In Excel 2013, the new workbook window will visibly overlap the initial workbook and any frozen view.  It will remain blank, but it will cover the initial workbook and any forms that were open.  This new focus also seems to affect other code created for use with previous versions of Excel.  What was considered the Active workbook when other workbooks are opened or closed reacts differently in 2013.  Even with screenupdating = false any changes in the "active" workbook will cause the currently active workbook to display on top causing flicker or covering userforms etc.  Also in 2013, if a form is opened immediately after opening a second workbook, that form will automatically close when the second workbook is closed. In this case UserForm_QueryClose  event will give a CloseMode value of 5.  There does not appear to be a documented value of 5 for CloseMode, however, VB6 has an UnloadMode value of 5 that refers to closing the form because the "owner" has closed.  This seems to fit the scenario described, but this did not happen in 2010.  I am using windows 8 and Excel 2013 64bit.  To ask a question; How can I prevent a newly opened workbook or "active" workbook from displaying on top of the primary workbook and userform?

推荐答案

我认为你可能会混淆 Application.ScreenUpdating的目的 with
Application.Visible ...

I think you may be confusing the purpose of Application.ScreenUpdating with Application.Visible...

即使是2010年如果我运行一个简单的子

Even with 2010 If I run a simple sub

Sub Main()
Application.ScreenUpdating = False

    Dim wb As Workbook
    Set wb = Application.Workbooks.Add

End Sub

新添加的 Book2 将保持领先,因为完成运行后的Sub本身将隐含地将
.ScreenUpdating 转换为 True

The newly added Book2 will stay on top because the Sub itself after finishing running will implicitly turn the .ScreenUpdating to True.

暂时忘记2010年与2013年的问题。我认为你的对象可能没有合适的资格。如果我是你,我会检查代码并确保不同的工作簿是合格的。确保您了解
.Visible 属性与 .SceenUpdating

Just forget the 2010 vs. 2013 issue for now. I think your objects may not have been properly qualified. If I was you I would go over the code and make sure that different workbooks are properly qualified. Make sure you understand the purpose of .Visible property vs. .SceenUpdating

 


这篇关于Excel 2013使用多个工作簿进行屏幕更新问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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