VBA/Excelで次の機能を試しています:
Sub function_name()
button.enabled=false
Call Long_Function ' duration: 10sec
button.enabled=true
End Sub
何らかの理由で、このボタンの無効化が機能しません (Excel ワークシートで有効のままです) DoEvents と遅延を試してみましたが、うまくいきませんでした。何か案は?ありがとう!
以下は私のために働きます(Excel 2010)
Dim b1 As Button
Set b1 = ActiveSheet.Buttons("Button 1")
b1.Font.ColorIndex = 15
b1.Enabled = False
Application.Cursor = xlWait
Call aLongAction
b1.Enabled = True
b1.Font.ColorIndex = 1
Application.Cursor = xlDefault
.enabled = False
ボタンがグレー表示されないことに注意してください。
フォントの色をグレー表示するには、明示的に設定する必要があります。
... ActiveX ボタンを使用しているかどうかはわかりませんが、CommandButton1 という Excel のシート 1 に ActiveX ボタンを挿入すると、次のコードが正常に動作します。
Sub test()
Sheets(1).CommandButton1.Enabled = False
End Sub
お役に立てれば...
これは、iDevelop が言おうとしていることです。
つまり、あなたは実際に を使用しています。enabled
あなたの最初の投稿はenable
..
次のことを試してみてください。
Sub disenable()
sheets(1).button1.enabled=false
DoEvents
Application.ScreenUpdating = True
For i = 1 To 10
Application.Wait (Now + TimeValue("0:00:1"))
Next i
sheets(1).button1.enabled = False
End Sub