我创建了一个用户表单,在宏仍在导入工作表时显示进度条。问题是,用户可以按下红色[X]按钮,关闭并中断处理过程。有没有办法隐藏这个“末日红色按钮”,使潜在用户在运行时不会有任何混淆的按钮可点击。
编辑: 我尝试过这个。
我收到了这个错误信息
编辑: 我尝试过这个。
'Find the userform's Window
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
'Get the current window style
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
'Set the new window style
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Const GWL_STYLE = -16
Const WS_SYSMENU = &H80000
我在 userform_initialize 中使用了这个
Dim hWnd As Long, lStyle As Long
'Which type of userform
If Val(Application.Version) >= 9 Then
hWnd = FindWindow("ThunderDFrame", Me.Caption)
Else
hWnd = FindWindow("ThunderXFrame", Me.Caption)
End If
'Get the current window style and turn off the Close button
lStyle = GetWindowLong(hWnd, GWL_STYLE)
SetWindowLong hWnd, GWL_STYLE, (lStyle And Not WS_SYSMENU)
我收到了这个错误信息
这段代码来自 此处链接。我不知道哪里出了问题,而且我已经删除了注释。这是我找到的最简单的代码,所以我想将其集成到我的用户表单中。任何帮助都将不胜感激。