Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to get the IP address using VBA ??

How to get the IP address using VBA ??

How to get the IP address using VBA ??

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 !!!!

RE: How to get the IP address using VBA ??

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
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

RE: How to get the IP address using VBA ??

Thank you very much, PHV !

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close