Вот нашел за 3 минуты на просторах интернета...
Проверил. Все работает
Код |
---|
Option Explicit
'----------------------------------------------------------------------------
'This module contains 3 functions for determing the public IP, the local IP
'and the MAC address of the computer that runs those functions.
'Written By: Christos Samaras
'Date: 22/11/2014
'E-mail: xristos.samaras@gmail.com
'Site: http://www.myengineeringworld.net
'----------------------------------------------------------------------------
Function GetMyPublicIP() As String
Dim HttpRequest As Object
On Error Resume Next
'Create the XMLHttpRequest object.
Set HttpRequest = CreateObject("MSXML2.XMLHTTP")
'Check if the object was created.
If Err.Number <> 0 Then
'Return error message.
GetMyPublicIP = "Could not create the XMLHttpRequest object!"
'Release the object and exit.
Set HttpRequest = Nothing
Exit Function
End If
On Error GoTo 0
'Create the request - no special parameters required.
HttpRequest.Open "GET", "http://myip.dnsomatic.com", False
'Send the request to the site.
HttpRequest.Send
'Return the result of the request (the IP string).
GetMyPublicIP = HttpRequest.ResponseText
End Function |