Function GetIP() As String Dim OpSysSet As Object, Op As Object, Ip Set OpSysSet = GetObject("winmgmts:{impersonationLevel=impersonate}//localhost").ExecQuery("SELECT index, IPAddress FROM Win32_NetworkAdapterConfiguration") For Each Op In OpSysSet If Not IsNull(Op.IPAddress) Then For Each Ip In Op.IPAddress If Ip Like "*.*.*.*" Then GetIP = Ip Exit Function End If Next End If Next End Function
标签:Function,VBA,End,IPAddress,IP,OpSysSet,Ip,本机,Op From: https://www.cnblogs.com/sonycat/p/sonycat_GetIP.html