Avoiding exceptions when populating XSICollections


Use the Items property. You won’t get any errors, you just have to check whether or not the collection is empty.

import win32com.client

oColl = win32com.client.Dispatch("XSI.Collection")
oColl.Unique = True
oColl.Items = "*.*.dontexist_*"
print oColl.Count

Leave a comment