Quería consultar sobre como podría hacer un msgbox que se cierre automáticamente después de ciertos segundos. Cabe decir que he buscado diferentes opciones y las pruebo y no se porque no me funciona, simplemente el msgbox queda allí y no se cierra.
Dejo acá las tres opciones que encontré pero que no me han funcionado, no sé si es que no he activado alguna librería. Quedo atento.
Option Explicit
Const TIMEOUT = 3 'Segundos
Sub MsgBoxTimer1()
Dim objShell As Object, intMsgBox As Variant
Set objShell = CreateObject("WScript.Shell")
intMsgBox = objShell.Popup("Mensaje Temporizado en 3 Segundos.", TIMEOUT, "exceltrabajaporti.com", 64)
Set objShell = Nothing
End Sub
Sub MsgBoxTimer2()
Dim SH As IWshRuntimeLibrary.WshShell
Dim Res As Long
Set SH = New IWshRuntimeLibrary.WshShell
Res = SH.Popup(Text:="Click Me", secondstowait:=5, _
Title:="Hello, World", Type:=vbOKOnly)
End Sub
Sub MsgBoxTimer3()
Dim AckTime As Integer, InfoBox As Object
Set InfoBox = CreateObject("WScript.Shell")
'Set the message box to close after 10 seconds
AckTime = 3
Select Case InfoBox.Popup("Click OK (this window closes automatically after 3 seconds).", _
AckTime, "This is your Message Box", 0)
Case 1, -1
Exit Sub
End Select
End Sub
Featured Replies
Archivado
Este tema está ahora archivado y está cerrado a más respuestas.
Buenas a todos,
Ante todo espero que estén bien.
Quería consultar sobre como podría hacer un msgbox que se cierre automáticamente después de ciertos segundos. Cabe decir que he buscado diferentes opciones y las pruebo y no se porque no me funciona, simplemente el msgbox queda allí y no se cierra.
Dejo acá las tres opciones que encontré pero que no me han funcionado, no sé si es que no he activado alguna librería. Quedo atento.
Option Explicit Const TIMEOUT = 3 'Segundos Sub MsgBoxTimer1() Dim objShell As Object, intMsgBox As Variant Set objShell = CreateObject("WScript.Shell") intMsgBox = objShell.Popup("Mensaje Temporizado en 3 Segundos.", TIMEOUT, "exceltrabajaporti.com", 64) Set objShell = Nothing End Sub Sub MsgBoxTimer2() Dim SH As IWshRuntimeLibrary.WshShell Dim Res As Long Set SH = New IWshRuntimeLibrary.WshShell Res = SH.Popup(Text:="Click Me", secondstowait:=5, _ Title:="Hello, World", Type:=vbOKOnly) End Sub Sub MsgBoxTimer3() Dim AckTime As Integer, InfoBox As Object Set InfoBox = CreateObject("WScript.Shell") 'Set the message box to close after 10 seconds AckTime = 3 Select Case InfoBox.Popup("Click OK (this window closes automatically after 3 seconds).", _ AckTime, "This is your Message Box", 0) Case 1, -1 Exit Sub End Select End Sub