View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Display in cell not dialogue box

This worked ok for me:

Option Explicit

Sub GetPhysAddress()
Dim oWMIService As Object
Dim oColAdapters As Object
Dim oObjAdapter As Object
Dim DestCell As Range

Set DestCell = ActiveSheet.Range("a1")

Set oWMIService = GetObject("winmgmts:" & "!\\.\root\cimv2")
Set oColAdapters = oWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each oObjAdapter In oColAdapters
DestCell.Value = oObjAdapter.MACAddress
Set DestCell = DestCell.Offset(1, 0)
Next

Set oObjAdapter = Nothing
Set oColAdapters = Nothing
Set oWMIService = Nothing
End Sub

Adjust the worksheet and range to what you want.

sparx wrote:

Hello All - how do I make the result of the following macro display its
result in an excel cell not the dialogue box?

Sub GetPhysAddress()
Dim oWMIService As Object
Dim oColAdapters As Object
Dim oObjAdapter As Object

Set oWMIService = GetObject("winmgmts:" & "!\\.\root\cimv2")
Set oColAdapters = oWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled =
True")

For Each oObjAdapter In oColAdapters
MsgBox "Adapter Physical address: " & oObjAdapter.MACAddress
Next

Set oObjAdapter = Nothing
Set oColAdapters = Nothing
Set oWMIService = Nothing
End Sub

--
sparx
------------------------------------------------------------------------
sparx's Profile: http://www.excelforum.com/member.php...o&userid=16787
View this thread: http://www.excelforum.com/showthread...hreadid=524275


--

Dave Peterson