find mac address of my own computer by excell macro

  • Thread starter INQUISITIVE DISCIPLE
  • Start date
I

INQUISITIVE DISCIPLE

I am using excell 2002. I want to find mac address of my own computer by
excell macro.
 
S

Steve Yandl

Give something like this a try.

'----------------------------------
Sub GetMAC()

Dim strLine As String
Dim bEther As Boolean

bEther = False
Set wsh = CreateObject("WScript.Shell")
Set wshExec = wsh.Exec("ipconfig /all")
Set objStdOut = wshExec.StdOut

Do Until objStdOut.AtEndOfStream
strLine = objStdOut.ReadLine
If InStr(strLine, "Ethernet") > 0 Then
bEther = True
End If

If InStr(strLine, "Physical Address") > 0 And bEther Then
strLine = Right(strLine, 17)
Exit Do
End If
Loop

MsgBox strLine

Set wshExec = Nothing
Set wsh = Nothing
End Sub

'----------------------------------

Steve Yandl
 
Top