当我处理一些东西的时候可以冻结Excel吗?

当我处理一些东西的时候可以冻结Excel吗? 我正在使用2007年。我已经知道冻结VBA表单的更新是可能的,但是我正在寻找一些冻结的东西(带有等待光标,也许是不错的东西,比如使窗口变暗) 。

有没有人曾经从VBA尝试过这样的事情?

有没有人曾经从VBA尝试过这样的事情?

是。 根据我所做的处理types,我隐藏了整个Excel应用程序,或者显示带有进度更新的用户窗体,以避免任何用户干扰

示例1 (隐藏应用程序)

Option Explicit Sub Sample() Application.Visible = False '~~> Rest of the code Application.Visible = True End Sub 

示例2 (使用禁用了“X”的用户窗体)

创build一个用户窗体并把这个代码放在那里

 Option Explicit Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, _ ByVal wFlags As Long) As Long Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Const MF_BYPOSITION = &H400& Private Sub UserForm_Initialize() Dim lHwnd As Long lHwnd = FindWindow("ThunderDFrame", "Please Wait...") Do While lHwnd = 0 lHwnd = FindWindow("ThunderDFrame", "Please Wait...") DoEvents Loop RemoveMenu GetSystemMenu(lHwnd, 0), 6, MF_BYPOSITION End Sub '~~> The below code will not be there '~~> This is just there so that if you try the above code then you can exit the form Private Sub UserForm_Click() Unload Me End Sub 

用法就是这样

 Option Explicit Sub Sample() UserForm1.Show vbModeless '~~> Rest of the code Unload UserForm1 End Sub 

要在处理期间冻结Excel,请将screenupdating设置为false。 请务必在完成后将其设置为true,否则用户将无法与Excel进行交互。 除了不会让用户在屏幕上闪烁一些动作,这大大加快了处理速度。

 Sub Sample() Application.ScreenUpdating = False '~~> Rest of the code Application.ScreenUpdating= True End Sub 

我同意JMax的一个进度条是一个很好的select。 你可以在这里find几个不同的Excel VBA进度条: http : //spreadsheetpage.com/index.php/blog/progress_bars_the_movie/

顺便说一句,你可以跳过电影,直接进入下面的链接。 你可能会觉得这部电影有趣,但是它所说的是“进度条=好,旋转的东西=坏”。