Using WIA Collection Objects

A collection is an object that contains one or more objects. Collections provide an efficient way of grouping similar objects. Windows Image Acquisition (WIA) provides collections for the DeviceInfo and Item objects.

Use collections to enumerate the objects they contain. For example, the following VBScript example obtains a collection of DeviceInfo objects from the Devices method and then uses a For...Each loop to iterate through the collection:

<SCRIPT LANGUAGE="VBScript">
Dim objWia
Dim objDeviceInfoCollection
Dim objDeviceInfo
 
Set objWIA = CreateObject("Wia.Script")
 
Set objDeviceInfoCollection = objWia.Devices
 
For Each objDeviceInfo In objDeviceInfoCollection
    ' Do something with the DeviceInfo object.
Next
</SCRIPT>

Note

WIA collection objects are 0-based.