Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get the IP address using VBA ?? 3

Status
Not open for further replies.

src23

Programmer
Jul 10, 2003
22
RO
HI !

Does anyone know how to get the IP address of a computer using VBA ?

I made log table, I have the back-end database on a server, and a few front-end files in the office, and i want to log all the users who access the back-end.

I used the Environ function, it provides me the computer name / user name and anything else i need, but it doesn't show the IP address. The functions I made are working, all I need is to get the IP address..

Please, I need urgent answer to this question ...

I couldn't do any search in this forum because this function is not available when i'm writing the message. I rmember i found a post on this forum some time ago about how to find the IP address, I looked after it but i
didnt find anything.... or maybe it wasn't on this forum...

If you can't answer but if you could give me the link to that post, or any ohter link, that would be great, too...

Thanx a lot !!!!
 
This is the function I personnally use:
Public Function getMyIP()
Dim myWMI As Object, myobj As Object, itm
Set myWMI = GetObject("winmgmts:\\.\root\cimv2")
Set myobj = myWMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each itm In myobj
getMyIP = itm.IPAddress(0)
Exit Function
Next
End Function

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank you very much, PHV !

It works fine, it's exactly what I was looking for !

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top