View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Just Another Yahoo![_2_] Just Another Yahoo![_2_] is offline
external usenet poster
 
Posts: 10
Default Output a string to the console?

Wow, cool Steve!

That works well for a single line of output but I would need the ability to
output as the program moves along, just like a log file. As is, this opens
a new command window every time it's called. Maybe I could make it into an
object... I'll play some more with it. Thanks for the assistance :-)
--
Toby Erkson
Excel 2003, WinXP

"Steve Yandl" wrote in message
...
Toby,

As I suggested in my earlier post, I suspect there is a more efficient way
to harvest output from the tasks your sheduler causes to execute.
However, if you do want text to a console window, here is an example. If
you launch this sub with some text as the argument, you get a command
interpreter console window (cmd.exe window) containing the text sent to
the sub. If the text argument is absent, you get the console window with
"Hello World"

'----------------------------------------------
Sub StringInConsole(Optional strMsg As String = "")

If Not Len(strMsg) 0 Then
strMsg = "Hello World"
End If

strMsg = "echo " & strMsg & "&echo off"

Shell "cmd.exe /k" & strMsg, vbNormalFocus

End Sub
'----------------------------------------------

That you could launch with a sub like
'---------------------------------------------
Sub MessageMe()
StringInConsole("This is a test of this fine VBA routine")
End Sub
'---------------------------------------------
or
'---------------------------------------------
Sub MessageMe()
StringInConsole
End Sub
'---------------------------------------------

Steve Yandl