Is there a way to get the port number associated to the local IP address with VBA, I know I can get the IP address with the VBA below:
Code:
Public Function getMyIP()
'Related Reference - Microsoft WMI Scripting V1.2 Library (wbemdisp.TLB)
'Define Variable Data Types
Dim objWMI As Object
Dim objQuery As Object
Dim objQueryItem As Object
Dim vIpAddress
'Create WMI Object
Set objWMI = GetObject("winmgmts:\\.\root\cimv2")
'Query WMI
Set objQuery = objWMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")
'Loop Thru all assigned IP Addresses
For Each objQueryItem In objQuery
Debug.Print vbCrLf & "All Assigned IP Addresses"
For Each vIpAddress In objQueryItem.IpAddress
Debug.Print "User IP - " & vIpAddress
Next
Next
End Function