Modifying VBA to work with 64bit Excel

I had this question after viewing Nslookup in Excel.

I get an error saying this module doesn't work in my 64bit Excel for

Private Declare Function InternetGetConnectedState Lib "wininet.dll" ( _
      ByRef lpdwFlags As Long, _
      ByVal dwReserved As Long _
   ) As Long

Private Declare Function gethostbyname Lib "wsock32" ( _
      ByVal HostName As String _
   ) As Long

Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" ( _
      ByRef Destination As Any, _
      ByRef Source As Any, _
      ByVal Length As Long _
   )

Public Declare Function WSAStartup Lib "wsock32" _
   (ByVal wVersionRequired As Long, _
    lpWSADATA As WSADATA) As Long
    
Public Declare Function WSACleanup Lib "wsock32" () As Long

Private Declare Function IcmpCreateFile Lib "icmp.dll" () As Long

Private Declare Function IcmpCloseHandle Lib "icmp.dll" ( _
      ByVal IcmpHandle As Long _
   ) As Long
   
Private Declare Function IcmpSendEcho Lib "icmp.dll" ( _
   ByVal IcmpHandle As Long, _
   ByVal DestinationAddress As Long, _
   ByVal RequestData As String, _
   ByVal RequestSize As Long, _
   ByVal RequestOptions As Long, _
   ReplyBuffer As ICMP_ECHO_REPLY, _
   ByVal ReplySize As Long, _
   ByVal Timeout As Long) As Long

Open in new window


What do I need to do to make it work?
Joshua WinbrookAsked:
Who is Participating?
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.

MacroShadowCommented:
    #If Win64 Then
		Private Declare PtrSafe Function gethostbyname Lib "WSOCK32.DLL" (ByVal hostname As String) As Long
        Private Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (xDest As Any, xSource As Any, ByVal nbytes As Long)
        Private Declare PtrSafe Function WSAStartup Lib "WSOCK32.DLL" (ByVal wVersionRequired As Long, lpWSADATA As WSADATA) As Long
        Private Declare PtrSafe Function WSACleanup Lib "WSOCK32.DLL" () As Long
        Public Declare PtrSafe Function IcmpCreateFile Lib "icmp.dll" () As Long
        Public Declare PtrSafe Function IcmpCloseHandle Lib "icmp.dll" (ByVal IcmpHandle As Long) As Long
        Private Declare PtrSafe Function IcmpSendEcho Lib "icmp.dll" _
           (ByVal IcmpHandle As Long, _
            ByVal DestinationAddress As Long, _
            ByVal RequestData As String, _
            ByVal RequestSize As Long, _
            ByVal RequestOptions As Long, _
            ReplyBuffer As ICMP_ECHO_REPLY, _
            ByVal ReplySize As Long, _
            ByVal Timeout As Long) As Long
    #Else
		Private Declare Function gethostbyname Lib "WSOCK32.DLL" (ByVal hostname As String) As Long
        Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (xDest As Any, xSource As Any, ByVal nbytes As Long)
        Private Declare Function WSAStartup Lib "WSOCK32.DLL" (ByVal wVersionRequired As Long, lpWSADATA As WSADATA) As Long
        Private Declare Function WSACleanup Lib "WSOCK32.DLL" () As Long
        Public Declare Function IcmpCreateFile Lib "icmp.dll" () As Long
        Public Declare Function IcmpCloseHandle Lib "icmp.dll" (ByVal IcmpHandle As Long) As Long
        Private Declare Function IcmpSendEcho Lib "icmp.dll" _
           (ByVal IcmpHandle As Long, _
            ByVal DestinationAddress As Long, _
            ByVal RequestData As String, _
            ByVal RequestSize As Long, _
            ByVal RequestOptions As Long, _
            ReplyBuffer As ICMP_ECHO_REPLY, _
            ByVal ReplySize As Long, _
            ByVal Timeout As Long) As Long
    #End If

Open in new window

0

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
Hans HallebeekCommented:
Instead of #If Win64 you can also use #If VBA7
0
MacroShadowCommented:
I don't see that you mentioned the GetStringFromIPAddress and GetIPAddressFromHostName functions anywhere in your question...
Without seeing the code there is no way we can debug it for you. Anyway, It should be asked in a new question as your initial question was answered.
0
Joshua WinbrookAuthor Commented:
Agreed, posted as a new question.  Thank you.
0
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
VBA

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.