View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld[_2_] Ron Rosenfeld[_2_] is offline
external usenet poster
 
Posts: 1,045
Default how to detect host id of a computer using excel

On Sat, 5 Jan 2013 08:33:39 -0800 (PST), wrote:

I want to create a file which is locked to host id of computer. can anyone tell me how to detect host id of a computer in excel.


Here's a routine to obtain the MACAddress, from
http://www.ehow.com/how_6920281_use-...c-address.html

============================
Option Explicit
Function GetMACAddress()
Dim objVMI As Object
Dim vAdptr As Variant
Dim objAdptr As Object
Dim adptrCnt As Long
Dim GetNetworkConnectionMACAddress As String
Set objVMI = GetObject("winmgmts:\\" & "." & "\root\cimv2")
Set vAdptr = objVMI.execquery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")

For Each objAdptr In vAdptr
If Not IsNull(objAdptr.MACAddress) And IsArray(objAdptr.IPAddress) Then
For adptrCnt = 0 To UBound(objAdptr.IPAddress)
If Not objAdptr.IPAddress(adptrCnt) = "0.0.0.0" Then
GetNetworkConnectionMACAddress = objAdptr.MACAddress
Exit For
End If
Next adptrCnt
MsgBox "Your MAC Address is: " & GetNetworkConnectionMACAddress
End If
Next objAdptr

End Function
======================================