EDN Admin
Well-known member
I get erros working with a colleciton
the line " For each objPrinter in colPrinters "
gives me an error:
Expression is of type Object, which is not a collection type.
<pre class="prettyprint lang-vb Dim strComputer As String
Dim objWMIService, colPrinters, objPrinter As Object
strComputer = OldPCTxtBx.Text
objWMIService = GetObject("winmgmts:\" & strComputer & "rootcimv2")
colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer")
For Each objPrinter In colPrinters
PrintersListBx.Items.Add(objPrinter.DeviceID)
WriteLog("Detected Printer " & (objPrinter.DeviceID) & vbCrLf)
Next[/code]
<br/><hr class="sig David Sheetz MCP
View the full article
the line " For each objPrinter in colPrinters "
gives me an error:
Expression is of type Object, which is not a collection type.
<pre class="prettyprint lang-vb Dim strComputer As String
Dim objWMIService, colPrinters, objPrinter As Object
strComputer = OldPCTxtBx.Text
objWMIService = GetObject("winmgmts:\" & strComputer & "rootcimv2")
colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer")
For Each objPrinter In colPrinters
PrintersListBx.Items.Add(objPrinter.DeviceID)
WriteLog("Detected Printer " & (objPrinter.DeviceID) & vbCrLf)
Next[/code]
<br/><hr class="sig David Sheetz MCP
View the full article