All collection objects support the COM interface IADsCollection. This interface is derived from IDispatch to make it a dual interface. The IADsCollection interface enables objects to define and manage an arbitrary set of named data elements for a directory service.
The name of the item to be added to the collection
The method retrieves an item of the collection
Removes the specified item. The name of the item to be removed is passed to the method. For instance, in the print job, the name of the print job, which is the job identifier is passed to the method. The method uses the job identifier passed to it and removes the corresponding print job from the print queue
The enumeration of the items in a collection works due to a hidden method, "_NewEnum". This method is directly called by VB.
Dim PrintQueueOperations As IADsPrintQueueOperations
Dim PrintJobCollection As IADsCollection
Dim PrintJob As IADsPrintJob
Dim PrintJobOperations As IADsPrintJobOperations
'Get the IADsPrintQueueOperations interface. In the path HP DeskJet '500C is the print queue.
Set PrintQueueOperations = GetObject ("NTDS://MSFT/MOON/HP DeskJet 500C")
Set PrintJobCollection = PrintQueueOperations.PrintJobs
'Enumerate individual print jobs and pause all the jobs
For each PrintJob In PrintJobCollection
Set PrintJobOperations = PrintJob