Retrieving MAC addresses

J

J.D. Haight

Folks,

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.
 
M

Martin Seelhofer

Hi 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top