How to get an IP address using Excel VBA on a network?


Posted by Kurt on September 11, 2000 7:34 PM

Does anybody out there have a macro to get an IP address from the network?

Thanks in advance!!

Kurt



Posted by Michael Liu on September 13, 0100 7:02 AM

You could do the following:
Create a DOS batch file that runs ipconfig and captures that
in a file:

ex:
File:IP.bat
Contents:
ipconfig > c:\ipstat.txt

Then you can have Excel call the script in VB using
the shell command, wait for it to complete, and then import
the text file with a ":" delimiter.
Your IP address will be in the second column and you can use
a vlookup to find the appropriate row.
The text file will look something like:

Windows NT IP Configuration

Ethernet adapter AMDPCN1:

IP Address. . . . . . . . . : 192.168.12.174
Subnet Mask . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . : 192.168.12.1


It's not pretty, but it will get the job done.