View Single Post
  #10   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?

Well, I was hoping to not have to build a string. The goal is to simply
open the command window and spit out text as the program plods along instead
of waiting until it finishes (for better or for worse) to output a built-up
string because that would require error checking code, which is something
I'd like to avoid. Remember, the scheduler app. I use captures the command
window output as the executing program runs so if the executing program
fails for any reason -- be it gracefully or catastrophically -- the [saved]
command window text would show me the last point of noted execution.

Background: The person I replaced wrote many scripts and VBA code but w/o
good error trapping. Right now it's faster for me to put in these sort of
"echo" statements at key points in the VBA code than set up error
trapping -- that would be a long task with too small of a return. This
method would give me a better idea where the error occurred instead of just
"somewhere in this workbook" and it would allow me to insert break points in
appropriate locations. As I come across the rare error I add my error
checking/trapping as necessary.
--
Toby Erkson
Excel 2003, WinXP

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

Take a look at the line from the routine
strMsg = "echo " & strMsg & "&echo off"
Notice how I placed the & characters when I sent echo commands. The &
character when fed to cmd.exe works much like vbCrLf when you're writing
VBA or VBS. In the line above, the first and second & are used to
concatenate my string but the one inside the quotes and right before "echo
off" causes the "echo off" to be sent as a new line (which turns off the
echo so you don't have the command prompt waiting after your final line of
text). Just build up the variable strMsg so that you keep adding the lines
of output but be sure to add in an & between each line. Then at the end,
use the line I placed to append the text string with the echo and 'echo
off'.

Steve Yandl