我创建了一个用户窗体以在宏仍在导入工作表时显示进度条
问题是用户可以按下红色的[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)
我收到此错误消息
此代码取自此处。我不知道我做错了什么,我已经删除了评论。这是我发现的最简单的代码,所以我想将它集成到我的用户表单中。任何帮助表示赞赏。