Diante de uma duvida surgida no nosso Forum, “FECHAR MSGBOX AUTOMATICAMENTE” coloco a solução criada pelo nosso colega JoseA :
Fechar MsgBoxs automáticamente por JoseA:
Global oSHL As Object
Sub AutoCloseMsgBox(Mensagem As String, Titulo As String, Segundos As Integer)
Set oSHL = CreateObject("WScript.Shell")
oSHL.PopUp Mensagem, Segundos, Titulo, vbOKOnly + vbInformation
End Sub
Sub AutoMessage()
'Fechar MsgBoxs automáticamente por JoseA
'Call Envia_A
AutoCloseMsgBox "Msgbox1 - Clique em OK ou aguarde 2 segundos", "Fechar MsgBox1 automaticamente", 2 '2 segundos
'Call Envia_B
AutoCloseMsgBox "Msgbox2 - Clique em OK ou aguarde 3 segundos", "Fechar MsgBox2 automaticamente", 3 '3 segundos
'Call Envia_C
AutoCloseMsgBox "Msgbox3 - Clique em OK ou aguarde 4 segundos", "Fechar MsgBox3 automaticamente", 4 '4 segundos
'Call Envia_D
AutoCloseMsgBox "Msgbox4 - Clique em OK ou aguarde 5 segundos", "Fechar MsgBox4 automaticamente", 4 '5 segundos
End Sub |
Global oSHL As Object
Sub AutoCloseMsgBox(Mensagem As String, Titulo As String, Segundos As Integer)
Set oSHL = CreateObject("WScript.Shell")
oSHL.PopUp Mensagem, Segundos, Titulo, vbOKOnly + vbInformation
End Sub
Sub AutoMessage()
'Fechar MsgBoxs automáticamente por JoseA
'Call Envia_A
AutoCloseMsgBox "Msgbox1 - Clique em OK ou aguarde 2 segundos", "Fechar MsgBox1 automaticamente", 2 '2 segundos
'Call Envia_B
AutoCloseMsgBox "Msgbox2 - Clique em OK ou aguarde 3 segundos", "Fechar MsgBox2 automaticamente", 3 '3 segundos
'Call Envia_C
AutoCloseMsgBox "Msgbox3 - Clique em OK ou aguarde 4 segundos", "Fechar MsgBox3 automaticamente", 4 '4 segundos
'Call Envia_D
AutoCloseMsgBox "Msgbox4 - Clique em OK ou aguarde 5 segundos", "Fechar MsgBox4 automaticamente", 4 '5 segundos
End Sub
Na rotina AutoMessage fiz menção somente às msgboxs após a execução de determinadas rotinas, é uma forma simples e direta, podemos fazer essas chamadas diretamente nas rotinas em que estaremos executando.
Essa dica foi postada no site abaixo, no mesmo temos uma outra dica utilizando-se APIS, mas optei por essta por ter menos linhas e ser mais simples.
MsgBox com Time
http://www.vbaexcelforum.com/showthread … 2615713e22