gpt4 book ai didi

Excel ScreenUpdating False 并且屏幕仍然闪烁

转载 作者:行者123 更新时间:2023-12-02 05:22:59 25 4
gpt4 key购买 nike

我有以下简单代码来关闭一系列打开的工作簿。我刚刚切换到 Excel 2013,在这个新版本中,对于每个未隐藏的工作簿,我的屏幕在 Excel 中不断闪烁一个白色窗口。

如何才能关闭烦人的屏幕闪烁?

Sub CloseFiles()
On Error Resume Next

Application.ScreenUpdating = False
Application.StatusBar = "Please wait while files are closed."
Application.DisplayAlerts = False

Dim rCell As Range
For Each rCell In Range("Files")
Application.StatusBar = "Closing file " & rCell.Value
If rCell.Value <> "" Then
Windows(rCell.Value).Visible = True
Workbooks(rCell.Value).Close SaveChanges:=True
End If
Next rCell

Application.WindowState = xlMaximized
Windows("Filename.xlsm").Activate

Application.DisplayAlerts = True
Application.StatusBar = False
Application.ScreenUpdating = True

End Sub

最佳答案

WindowStateDisplayAlerts结合使用。用户不会看到窗口最小化,但它也会防止 Excel 在另存为、更改窗口可见性或更改工作簿/工作表保护期间闪烁。

Dim iWindowState as Integer

With Application
.ScreenUpdating = False
.DisplayAlerts = False
iWindowState = .WindowState
.WindowState = xlMinimized
End With

'Flickery code

With Application
.ScreenUpdating = True
.DisplayAlerts = True
.WindowState = iWindowState
End With

关于Excel ScreenUpdating False 并且屏幕仍然闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21721513/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com