ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   find mac address of my own computer by excell macro (https://www.excelbanter.com/excel-programming/440565-find-mac-address-my-own-computer-excell-macro.html)

INQUISITIVE DISCIPLE

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

Steve Yandl[_3_]

find mac address of my own computer by excell macro
 
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


"INQUISITIVE DISCIPLE" <INQUISITIVE
wrote in message ...
I am using excell 2002. I want to find mac address of my own computer by
excell macro.



madirish

Steve

the below formula is great but is it possable to enter the MAC address in to a cell (eg A1 Sheet1) instead of a message box

regards

chris


Quote:

Originally Posted by Steve Yandl[_3_] (Post 1579085)
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


"INQUISITIVE DISCIPLE" <INQUISITIVE
wrote in message ...
I am using excell 2002. I want to find mac address of my own computer by
excell macro.



All times are GMT +1. The time now is 09:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com