When you use the iProperties.Value() shortcut, it targets the 'active' document, which doesn't seem like it would be a problem in this case, but just in case it is the (or a) problem here, I've decided to go through the process the longer (standard) route. You could have looped through the custom iProperties to find these two when going the longer route, but I chose the Try...Catch...End Try path, because they will produce the same outcome, with maybe a slight difference in performance, one way or the other.
Give this a try.
Dim oDoc As Document
For Each oDoc In ThisApplication.Documents.VisibleDocuments
'only process drawing documents
If oDoc.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Continue For
Dim oCProps As PropertySet = oDoc.PropertySets.Item(4) 'always the 'Custom' set
Dim oColour, oClass2 As Inventor.Property
Try
oColour = oCProps.Item("Colour")
Catch
MsgBox("Couldn't find 'Colour' property in " & oDoc.FullDocumentName, , "")
Continue For 'skip to next document in loop
End Try
Try
oClass2 = oCProps.Item("Class 2")
Catch
oClass2 = oCProps.Add("", "Class 2")
Catch
MsgBox("Couldn't find or create 'Class 2' property in " & oDoc.FullDocumentName)
Continue For 'skip to next document in loop
End Try
If oColour.Value = "RAL 9006" Then
oClass2.Value = "x"
End If
Next oDoc
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS
Wesley Crihfield

(Not an Autodesk Employee)