VBA 自动定时关闭的msgbox对话框

标准模块中插入如下代码

最后参数dwTimeout表示要设置的时间(单位:毫秒),2000就表示2秒。

Declare PtrSafe Function MessageBoxTimeout Lib "user32" Alias "MessageBoxTimeoutA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long, ByVal wlange As Long, ByVal dwTimeout As Long) As Long
Sub test()
     MessageBoxTimeout 0, "兩秒后自動關閉", "測試", 0, 1, 2000
End Sub

你可能感兴趣的:(VBA,VBA)