View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Kevin Kevin is offline
external usenet poster
 
Posts: 504
Default Pipe to cmd from excel and back

This is AWESOME, simple and to the point. Something I've wanted for a long
time.

One question though... Is there a way to make the command window open up in
the background so that as the spreadsheet is sending and recieving commands
that I can be reading my email or in some other application?

I'm using this method to run queries against a storage array and it takes
about 20 minutes or so to go through all of the commands needed and with the
window going back and forth from excel to cmd I can't do anything else until
it finishes...

Thanks in advance!! Thhis is a great help!!

Kevin Green

"Steve Yandl" wrote:

Here is one option using the WScript.Shell object (borrowed from scripting).
In the example below, ping is run on Google and the output is written to
Column A on the active sheet starting in A1. The cmd.exe window does appear
briefly.

'____________________________________________

Sub FetchPingOutput()
Dim strLine As String
Dim R As Integer

R = 1

Set wsh = CreateObject("WScript.Shell")
Set wshExecPng = wsh.Exec("ping 66.102.7.104")
Set wshStdOut = wshExecPng.StdOut

Do Until wshStdOut.AtEndOfStream
strLine = wshStdOut.ReadLine
Cells(R, 1).Value = strLine
R = R + 1
Loop

Set wsh = Nothing
End Sub


'____________________________________________

Steve Yandl



"Francogrex" wrote in message
...
Hi is there a way to pipe a command to the cmd (or run an exe) in
silent mode from excel and have the output of the exe returned into
excel spreadsheet? For those who are familiar with SAS, there is a
macro called %xlst, I was hoping to find something similar in excel.
Thanks.