How does one retrieve the computer MAC address using VBA?
I've got an automated date/user stamp feature that's working nicely in
Access, but would like to further confirm with the MAC address.
Thanks,
J.D.
> How does one retrieve the computer MAC address using VBA?
Here's a hint:
Function getMACAddress() As String
Dim wbm As Object
Dim configset As Object
Dim el
Set wbm = CreateObject("winmgmts:\\localhost\")
Set configset = wbm.InstancesOf("Win32_NetworkAdapterConfiguration")
For Each el In configset
If InStr(1, el.Caption, "Network") > 0 Then
getMACAddress = el.MacAddress
End If
Next
End Function
However, since there might be (and probably are) multiple network
adapters, you somehow must identify the actual LAN-card. In my
case, this was possible in the way demonstrated above (--> look
for string "Network" in the caption-property). This might not be the
case for your configuration, though...
Cheers,
Martin