procName = "IPアドレス取得"
Set accessLog = CreateObject("Scripting.Dictionary")
'--- IPアドレス
Set NetAdapters = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") _
.ExecQuery("Select * from Win32_NetworkAdapterConfiguration " & _
"Where (IPEnabled = TRUE)")
For Each objNic In NetAdapters 'ネットワークアダプターは、複数ある場合がある
For Each strIPAddress In objNic.IPAddress 'IPは、複数割り当てられている場合がある
resIP = strIPAddress
Exit For ' 1回のみ
Next
Exit For ' 1回のみ
Next
debug.print "IPアドレス=" & resIP
---結果---
IPアドレス=123.456.789.001
※コメント投稿者のブログIDはブログ作成者のみに通知されます