ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Message box that does not interrupt code (https://www.excelbanter.com/excel-programming/279250-message-box-does-not-interrupt-code.html)

Claude

Message box that does not interrupt code
 
Hi all,

Is it possible to configure the msgbox() in such a way
that a message is displayed (say for a few seconds, or
until another event takes place), without interrupting the
execution of the code?

Thanks in advance!

Don Guillett[_4_]

Message box that does not interrupt code
 
Here is one I found in the archives
http://tinyurl.com/qgdb
Sub TimedMessage()
Const Title As String = "Self closing message box"
Const Delay As Byte = 2 ' Tps d'affichage en secondes
Const wButtons As Integer = 16 ' Boutons + icone
Dim wsh As Object, msg As String
Set wsh = CreateObject("WScript.Shell")
msg = Space(10) & "Bonjour," & vbLf & vbLf & "Nous sommes le " & Date
wsh.Popup msg, Delay, Title, wButtons
Set wsh = Nothing
End Sub


"Claude" wrote in message
...
Hi all,

Is it possible to configure the msgbox() in such a way
that a message is displayed (say for a few seconds, or
until another event takes place), without interrupting the
execution of the code?

Thanks in advance!




[email protected]

Message box that does not interrupt code
 
Here's a link that discusses some options.
http://www.google.com/groups?num=50&...=Google+Search

================================================== =========================

Sub DisplayMessageWScript()
'' Display a MsgBox for two seconds.

Dim intSec As Integer
Dim WshShell2 As Object
Dim strText As String, strTitle As String

intSec = 2
strTitle = "PopUp Message"
strText = "Displays for " & intSec & " second."

Set WshShell2 = CreateObject("WScript.Shell")
WshShell2.Popup strText, intSec, strTitle

End Sub

================================================== =========================

Sub DisplayMessageWSH()
'' Set a reference to "Windows Script Host Object Model"

Dim SH As IWshRuntimeLibrary.WshShell

Set SH = New IWshRuntimeLibrary.WshShell
SH.Popup "Hello World", 5, "Title", vbYesNo

End Sub

================================================== =========================

Watch for linewrap here. Just call this routine with the string that
you wish to display.

Sub DisplayTextBox(strShow As String)
'' Displays a text box for a given amount of time.

Dim intLen As Integer
Dim shpTB As Shape

Application.ScreenUpdating = True

intLen = Len(strShow)

Set shpTB =
ActiveSheet.Shapes.AddTextbox(msoTextOrientationHo rizontal, 0, 0, 140,
15)
With shpTB
.Top = ActiveWindow.VisibleRange.Top + 250
.Left = ActiveWindow.VisibleRange.Left + 350
.Width = intLen * 5
.Fill.ForeColor.SchemeColor = 8
With .TextFrame.Characters
.Text = strShow
With .Font
.ColorIndex = 4
.FontStyle = "Bold Italic"
.Size = 9
End With
End With
End With

Application.Wait (Now + TimeValue("0:00:03"))

shpTB.Delete

End Sub

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------

Is it possible to configure the msgbox() in such a way
that a message is displayed (say for a few seconds, or
until another event takes place), without interrupting the
execution of the code?

Thanks in advance!




All times are GMT +1. The time now is 08:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com