Кто-нибудь когда-нибудь пробовал такое с VBA?
Да. В зависимости от вида обработки, которую я делаю, я либо скрываю приложение Excel целиком, либо показываю пользовательскую форму с обновлением прогресса, чтобы избежать вмешательства пользователя
Пример 1 (скрытие приложения)
Option Explicit
Sub Sample()
Application.Visible = False
'~~> Rest of the code
Application.Visible = True
End Sub
Пример 2 (Использование пользовательской формы, у которой отключен «X»)
Создайте пользовательскую форму и поместите туда этот код
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