I have a piece of code running in a form that idenifys the name of the PC that it is on. I currenly run it on 12 different machines and it works on them all, except one. The code I'm running is:
The error I'm getting is on the line
Its only happening on one machine, anyone help on this please?
Code:
Private Sub Form_Load()
Dim objWMIService As Object
Dim colAdapters As Object
Dim strComputer As String
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
n = 1
For Each objAdapter In colAdapters
'Me.Text0 = objAdapter.MACAddress
If Not IsNull(objAdapter.IPAddress) Then
For I = 0 To UBound(objAdapter.IPAddress)
Me.Text1 = objAdapter.IPAddress(I)
Next
End If
n = n + 1
Next
If Me.Text1 = "3.3.12.8" Then
Me.OCANo = "OCA 1 MCC"
End If
If Me.Text1 = "9.0.0.244" Then
Me.OCANo = "OCA 1 AAR"
End If
If Me.Text1 = "3.3.13.8" Then
Me.OCANo = "OCA 2 MCC"
End If
If Me.Text1 = "3.3.14.8" Then
Me.OCANo = "OCA 3 MCC"
End If
If Me.Text1 = "3.3.15.8" Then
Me.OCANo = "OCA 4 MCC"
End If
If Me.Text1 = "3.3.16.8" Then
Me.OCANo = "OCA 5 MCC"
End If
If Me.Text1 = "3.3.17.8" Then
Me.OCANo = "OCA 6 MCC"
End If
Me.Exercise_Date = Now()
End Sub
The error I'm getting is on the line
Code:
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Its only happening on one machine, anyone help on this please?