Sign in with
Sign up | Sign in
Your question

Ip address in windows 7

Tags:
  • Configuration
  • IP Address
  • Excel Macro
  • Windows 7
Last response: in Windows 7
Share
September 27, 2010 8:38:38 AM

using an excel macro how do I find the ip address of the machine i am currently on

More about : address windows

a b $ Windows 7
September 27, 2010 12:21:24 PM

Using VBA, you can use this code to return the IP address into cell A1:

  1. Option Explicit
  2.  
  3. Sub IPtest()
  4. Dim wsh As Object
  5. Dim RegEx As Object, RegM As Object
  6. Dim FSO As Object, fil As Object
  7. Dim ts As Object, txtAll As String, TempFil As String
  8. Set wsh = CreateObject("WScript.Shell")
  9. Set FSO = CreateObject("Scripting.FileSystemObject")
  10. Set RegEx = CreateObject("vbscript.regexp")
  11. TempFil = "C:\myip.txt"
  12. ' Save ipconfig info to temporary file
  13. wsh.Run "%comspec% /c ipconfig > " & TempFil, 0, True
  14. With RegEx
  15. .Pattern = "(\d{1,3}\.){3}\d{1,3}"
  16. .Global = False
  17. End With
  18. Set fil = FSO.GetFile(TempFil)
  19. ' Access temporary file
  20. Set ts = fil.OpenAsTextStream(1)
  21. txtAll = ts.ReadAll
  22. Set RegM = RegEx.Execute(txtAll)
  23. ' Return IP address to Activesheet cell A1 by parsing text
  24. ActiveSheet.Range("A1").Value = RegM(0)
  25. ActiveSheet.Range("A1").EntireColumn.AutoFit
  26. ts.Close
  27. ' Remove temp file
  28. Kill TempFil
  29.  
  30. Set ts = Nothing
  31. Set wsh = Nothing
  32. Set fil = Nothing
  33. Set FSO = Nothing
  34. Set RegM = Nothing
  35. Set RegEx = Nothing
  36. End Sub
a b $ Windows 7
September 27, 2010 4:48:50 PM

Or just go HERE :lol:  and u skip the excel macro
Related resources
a b $ Windows 7
September 27, 2010 4:51:56 PM

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!
a b $ Windows 7
September 27, 2010 6:07:04 PM

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