Consulting

Results 1 to 6 of 6

Thread: Solved: Showing IP Address

  1. #1
    VBAX Tutor
    Joined
    Sep 2007
    Posts
    265
    Location

    Solved: Showing IP Address

    Hi Guys,

    Can you advise me on how to detect user IP address.
    If it is possible thru vba, please send me a sample code.

    Many thanks in advance.
    Rgds, Harto

  2. #2

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    This shorter version works for me

    [vba]

    Set IPConfigSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
    ("select IPAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

    For Each IPConfig In IPConfigSet
    If Not IsNull(IPConfig.IPAddress) Then
    For i = LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
    Debug.Print IPConfig.IPAddress(i)
    Next
    End If
    Next
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Tutor
    Joined
    Sep 2007
    Posts
    265
    Location
    Dear All,

    Thanks a lot. That's work fine.

    unbelievable, bob! you are a master.

    Best,
    Harto

  5. #5
    VBAX Regular
    Joined
    Jul 2008
    Location
    Richardson, Texas
    Posts
    8
    Location

    reference in VBA

    Quote Originally Posted by xld
    This shorter version works for me

    [vba]

    Set IPConfigSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
    ("select IPAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

    For Each IPConfig In IPConfigSet
    If Not IsNull(IPConfig.IPAddress) Then
    For i = LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
    Debug.Print IPConfig.IPAddress(i)
    Next
    End If
    Next
    [/vba]

    What reference in VBA should we use for this to work?

    Sincerely,

    DragonLancer

  6. #6
    Knowledge Base Approver VBAX Master Oorang's Avatar
    Joined
    Jan 2007
    Posts
    1,135
    Location
    /me gives bob stars
    Cordially,
    Aaron



    Keep Our Board Clean!
    • Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
    • Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •