マクロがまだシートをインポートしているときに進行状況バーを表示するユーザーフォームを作成しました
問題は、ユーザーが赤い[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)
このエラーメッセージが表示されます
このコードはhereから取得されました。何が間違っているのかわからず、すでにコメントを削除しました。これは私が見つけた最も単純なコードなので、ユーザーフォームに統合したいと思います。どんな助けでも大歓迎です。