چطور میشه به مک ادرس سیستم از طریق اکسل دسترسی پیدا کرد؟ (یعنی مثل تابع now() که تایم رو از روی سیستم موردنظر برمیداره)
مک ادرس
Collapse
X
-
سلام دوست عزیز
یک کد در یک سایت پیدا کردم. تست کردم جواب میده.
دقت کنید که این کد بصورت فانکشن هستکد:Public Function GetNetworkConnectionMACAddress() As String ' Return the currently used network adapter's MAC address ' Syntax ' GetNetworkConnectionMACAddress() Dim oWMIService As Object Dim vAdapters As Variant Dim oAdapter As Object Dim lIndex As Long Dim lMatchIndex As Long Dim vResult As Variant ' Adapters are pulled from the Windows Management Instrumentation database ' The currently used adapter has a MAC address and an IP address that is not 0.0.0.0 Set oWMIService = GetObject("winmgmts:\\" & "." & "\root\cimv2") Set vAdapters = oWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True") For Each oAdapter In vAdapters If Not IsNull(oAdapter.MACAddress) And IsArray(oAdapter.IPAddress) Then lMatchIndex = -1 For lIndex = 0 To UBound(oAdapter.IPAddress) If Not oAdapter.IPAddress(lIndex) = "0.0.0.0" Then lMatchIndex = lIndex Exit For End If Next lIndex If Not lMatchIndex < 0 Then GetNetworkConnectionMACAddress = oAdapter.MACAddress End If End If Next End Function
لینک منبع:
Get mac address from PC using Excel VBA -
کامنت




کامنت