ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   External Commands? (https://www.excelbanter.com/excel-programming/373234-external-commands.html)

Linn Kubler

External Commands?
 
Hi,

This is probably beyond what an Excel Macro can do but I thought I'd ask
anyhow. Using Excel 2003, is it possible to run windows commands from
within Excel and return the results to a spreadsheet? What I'm trying to do
is ping a range of IP addresses, 192.168.1.1 - 192.168.1.100, and return the
results to a worksheet so I can see what IP addresses are already assigned
on my network and what they are assigned to. My predesesor didn't bother to
keep a list of used IP addresses.

Thanks in advance,
Linn



Tom Ogilvy

External Commands?
 
You should be able to adapt any of these to VBA (0r most of them)

http://vbnet.mvps.org/code/internet/index.html
Randy Birch's site
Look down the list to see code related to PING.

--
Regards,
Tom Ogilvy


"Linn Kubler" wrote:

Hi,

This is probably beyond what an Excel Macro can do but I thought I'd ask
anyhow. Using Excel 2003, is it possible to run windows commands from
within Excel and return the results to a spreadsheet? What I'm trying to do
is ping a range of IP addresses, 192.168.1.1 - 192.168.1.100, and return the
results to a worksheet so I can see what IP addresses are already assigned
on my network and what they are assigned to. My predesesor didn't bother to
keep a list of used IP addresses.

Thanks in advance,
Linn




Steve Yandl

External Commands?
 
You could modify something like this to run through the range rather than
just pull the results for one IP as this example does.

Sub PingAnIP()
Dim R As Integer
Dim strIP As String

R = 1
strIP = "192.168.1.1"

Set objShell = CreateObject("WScript.Shell")
Set objExecPing = objShell.Exec("Ping " & strIP)
Set objPingOutput = objExecPing.StdOut

Do Until objPingOutput.AtEndOfStream
strLine = objPingOutput.ReadLine
If Len(strLine) 2 Then
Cells(R, 1).Value = strLine
R = R + 1
End If
Loop

End Sub

Steve

"Linn Kubler" wrote in message
...
Hi,

This is probably beyond what an Excel Macro can do but I thought I'd ask
anyhow. Using Excel 2003, is it possible to run windows commands from
within Excel and return the results to a spreadsheet? What I'm trying to
do is ping a range of IP addresses, 192.168.1.1 - 192.168.1.100, and
return the results to a worksheet so I can see what IP addresses are
already assigned on my network and what they are assigned to. My
predesesor didn't bother to keep a list of used IP addresses.

Thanks in advance,
Linn





Linn Kubler

External Commands?
 
Thanks Tom, I'm worried that adapting something like this for VBA is a bit
involved for my skill set right now but I'll give it a wirl. Looks like a
number of handy functions on that site.
Linn

"Tom Ogilvy" wrote in message
...
You should be able to adapt any of these to VBA (0r most of them)

http://vbnet.mvps.org/code/internet/index.html
Randy Birch's site
Look down the list to see code related to PING.

--
Regards,
Tom Ogilvy


"Linn Kubler" wrote:

Hi,

This is probably beyond what an Excel Macro can do but I thought I'd ask
anyhow. Using Excel 2003, is it possible to run windows commands from
within Excel and return the results to a spreadsheet? What I'm trying to
do
is ping a range of IP addresses, 192.168.1.1 - 192.168.1.100, and return
the
results to a worksheet so I can see what IP addresses are already
assigned
on my network and what they are assigned to. My predesesor didn't bother
to
keep a list of used IP addresses.

Thanks in advance,
Linn







All times are GMT +1. The time now is 10:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com