Enumerating All Consumables in All Consumable Categories

The following VBA code will retrieve from a ProDesigner document the names of all consumable categories in the Process and for each category will enumerate over all consumables. In this code we assume that the variable SuperProDoc is a global variable that has been assigned to a document object of an SPD file.

Function GetAllConsumableNames()

Dim bContinue as Boolean

Dim consumableCategoryName, consumableName as Variant

Dim pos as Variant

Dim allConsumableNames as String

bContinue = SuperProDoc.StartEnumeration(pos, _

                                   ListTypeID.consumableCategory_LID, _

                                                                                                                                                  ContainerTypeID.flowsheet_CID, _         “”)

Do While (bContinue)

   bContinue = SuperProDoc.GetNextItemName(pos,       _

                                                                                                                                                     consumableCategoryName, _

                                   ListTypeID.consumableCategory_LID, _

                                                                                                                                                              ContainerTypeID.flowsheet_CID, _

                                   “”)

Dim bContinue2 As Boolean

Dim pos2 As Variant

bContinue2 = SuperProDoc.StartEnumeration(pos2, _

                                      ListTypeID.consumable_LID, _

                                                                                                                                ContainerTypeID.consumableCategory_CID, _

                                consumableCategoryName)

Do While (bContinue)

   bContinue = SuperProDoc.GetNextItemName(pos2,       consumableName, _

                                                                                                                    ListTypeID.consumable_LID, _

                                                                                                                    ContainerTypeID.consumableCategory_CID, _

                                                                                                                    consumableCategoryName)

 

  allConsumableNames = allConsumableNames + CStr(consumableName) + " "

 

Loop

Loop

End Function

 

With the above enumeration it is possible to find out the consumables and their category which are currently used in a process file. The consumable’s name together with its category name will be needed to make other COM calls to find out information on the consumable. See Equipment Variables used with GetEquipVarVal3 and Flowsheet Variables used with GetFlowsheetVarVal3.