よくありそうで すぐにつくれないので ここに記録します。
Private Sub mc()
' MsgBox (fnc_getMacAddress)
MsgBox (fnc_GetMacAdrs)
End Sub
' MsgBox (fnc_getMacAddress)
MsgBox (fnc_GetMacAdrs)
End Sub
Public Function fnc_GetMacAdrs() As String ' ????_MAC?A?h???X????()
Dim objConf, objMACEna, strIP
Set objConf = GetObject("winmgmts:\\.\root\cimv2").ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where (IPEnabled = TRUE)")
Dim objConf, objMACEna, strIP
Set objConf = GetObject("winmgmts:\\.\root\cimv2").ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where (IPEnabled = TRUE)")
For Each objMACEna In objConf
For Each strIP In objMACEna.IPAddress
fnc_GetMacAdrs = Replace(objMACEna.MACAddress, ":", "")
Exit For
Next
Next
End Function
For Each strIP In objMACEna.IPAddress
fnc_GetMacAdrs = Replace(objMACEna.MACAddress, ":", "")
Exit For
Next
Next
End Function
参考サイト