以下的功能代码是:通过VBA获取本机网卡的MAC地址。
Dim MyMac
Set MyMac = GetObject("Winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
For Each MyMacAddress In MyMac
If MyMacAddress.IPEnabled = True Then
MsgBox "本机网卡MAC地址是:" & MyMacAddress.MacAddress
Exit For
End If
Next
经过本站严格测试,以上代码正确无误!希望对您有所帮助。