I am using Visual Basic for Applications (Excel) to validate an IP Host is live before attempting any network related functions.
Posted on 2004-11-05
(Im a new programmer, so please bare with me :) )
I would prefer to use the shell function to run ping and redirect the output to a text file.
when I have attempted to this.
1. the ping command runs fine.
2. it does not write out to a text file... here is my code:
Private Sub CommandButton1_Click()
IP = "127.0.0.1"
COMND = "PING -N 1 127.0.0.1 > C:\TEST.TXT"
PING = COMND & " " & IP
bla = shell(PING)
Another method I tried with the shell function was to call a batch file.
The Batch file contains the following code:
PING -N 1 127.0.0.1 > C:\TEST.TXT
When ran from a command prompt this batch file works...however, if I try using the shell function as follows....
bla = shell("c:\pingip.bat")
It does not run the batch file.
any help on this would be greatly appreciated.