Unable to get correct IP using this NSLookup macro

I had this question after viewing Nslookup in Excel.

I have domain name in A1 and the formula "=GetStringFromIPAddress(GetIPAddressFromHostName(A1))" in B1, using the macro found above along with the authors update.  However no matter what domain I use I get instead of the IP.  Any help would be appreciated.
Joshua WinbrookAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Instead of using API calls which are a pain to debug as well as platform specific, you can use this function:
Option Explicit

Function ResolveAddress(strInput As String) As String

    Dim objShell As Object, objFSO As Object, objFile As Object
    Dim strParams As String, strFile As String, strOutput As String, strText As String, strHost As String

    strFile = Environ("USERPROFILE") & "\Documents\out.txt"
    Set objShell = CreateObject("wscript.shell")
    strParams = "%comspec% /c NSlookup " & strInput & " > " & strFile
    objShell.Run (strParams), 0, True
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.openTextFile(strFile)
    Do Until objFile.AtEndOfStream
        strText = objFile.ReadLine
        If IsNumeric(Replace(strInput, ".", "")) Then
            If InStr(strText, "Name:") Then
                strText = Right(strText, Len(strText) - InStr(strText, "."))
                strHost = Replace(strText, "Name: ", "")
            End If
            If Len(strText) > 0 Then strHost = Trim(Right(strText, Len(strText) - 1))
        End If

    objFSO.DeleteFile strFile
    If strHost = "" Then
        ResolveAddress = "Not Found"
        ResolveAddress = strHost
    End If
End Function

Open in new window

Then you can use it in a formula as such:

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Joshua WinbrookAuthor Commented:
Thank you!
Joshua WinbrookAuthor Commented:
Actually using the above code disables the ability to use arrow keys to navigate around the document, and hangs my PC.
That is strange.
Did you try debugging the code?
Place a breakpoint at he beginning of the code and then step through it line by line.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.