PDA

View Full Version : Message Box Code!



JuniorASA
11-30-2006, 09:20 AM
I am now writing a macro.

This macro shows a message box to have following message

"Macro Macro1 has been completed."

Right now I would like to have three message instead of one.

i.e.

"Macro Macro1 has been completed."

"The running begin at XX:XXpm"

"The running end at XX:XXpm"

"The total running time is yy min"

how could I modify below code to reach 4 message in separate line instead of one.

Many Thanks,

Sub Starting()
Dim MacroName, StartTime, EndTime, TimeDiff

MacroName = "Macro1"
Application.Run MacroName
Msg = "Macro" & MacroName & "has been completed."
Style = vbOKOnly
Title = "Macro Message Box"
Help = "DEMO.HLP"
Ctxt = 1000
Response = MsgBox(Msg, Style, Title, Help, Ctxt)

End Sub

Simon Lloyd
11-30-2006, 12:28 PM
Hi i dont knw how to do the timings in your message box but i have split the message box p ready for your timer variables


MsgBox "Macro" & MacroName & "has been completed." & Chr(13) & "The running begin at " & "XX:XX" & Chr(13) & "The running end at " & "XX:XXpm" & Chr(13) & "The total running time is " & "yy min", vbOKOnly, "Macro Message Box", "Demo.help", 1000
Regards,
Simon

Bob Phillips
11-30-2006, 12:56 PM
Sub Starting()
Dim MacroName As String
Dim StartTime As Double
Dim EndTime As Double
Dim TimeDiff As Double

StartTime = Now
MacroName = "Macro1"
Application.Run MacroName
EndTime = Now
TimeDiff = EndTime - StartTime
Msg = "Macro " & MacroName & "has been completed." & vbNewLine & _
"The running began at " & Format(StartTime, "hh:mm AM/PM") & vbNewLine & _
"The running finished at " & Format(EndTime, "hh:mm AM/PM") & vbNewLine & _
"Total run time was " & Round(TimeDiff * 24 * 60 * 60, 1) & " seconds"
Style = vbOKOnly
Title = "Macro Message Box"
Help = "DEMO.HLP"
Ctxt = 1000
Response = MsgBox(Msg, Style, Title, Help, Ctxt)

End Sub