Ip address in windows 7

using an excel macro how do I find the ip address of the machine i am currently on
4 answers Last reply
More about address windows
  1. Using VBA, you can use this code to return the IP address into cell A1:

    [cpp]Option Explicit

    Sub IPtest()
    Dim wsh As Object
    Dim RegEx As Object, RegM As Object
    Dim FSO As Object, fil As Object
    Dim ts As Object, txtAll As String, TempFil As String
    Set wsh = CreateObject("WScript.Shell")
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set RegEx = CreateObject("vbscript.regexp")
    TempFil = "C:\myip.txt"
    ' Save ipconfig info to temporary file
    wsh.Run "%comspec% /c ipconfig > " & TempFil, 0, True
    With RegEx
    .Pattern = "(\d{1,3}\.){3}\d{1,3}"
    .Global = False
    End With
    Set fil = FSO.GetFile(TempFil)
    ' Access temporary file
    Set ts = fil.OpenAsTextStream(1)
    txtAll = ts.ReadAll
    Set RegM = RegEx.Execute(txtAll)
    ' Return IP address to Activesheet cell A1 by parsing text
    ActiveSheet.Range("A1").Value = RegM(0)
    ActiveSheet.Range("A1").EntireColumn.AutoFit
    ts.Close
    ' Remove temp file
    Kill TempFil

    Set ts = Nothing
    Set wsh = Nothing
    Set fil = Nothing
    Set FSO = Nothing
    Set RegM = Nothing
    Set RegEx = Nothing
    End Sub

    [/cpp]
  2. Or just go HERE :lol: and u skip the excel macro
  3. Yeah, that's the easiest, but I'm assuming he must be wanting it for SOME sort of Excel app. Not sure why, but hey, each to his own!
  4. Two different approaches that will, in most cases, give two different answers!

    OP - do you require the true IP address of your computer or that which the outside world sees? Perhaps if you can explain why you require this information it might help.
Ask a new question

Read More

Configuration IP Address Excel Macro Windows 7