The following VBA code will retrieve from a ProDesigner document the names of all unit procedures. In this code we assume that the variable SuperProDoc is a global variable that has been assigned to an SPD file.
Function GetAllProcedureNames()
Dim bContinue as Boolean
Dim procName as Variant
Dim pos as Variant
Dim allProcNames as String
bContinue = SuperProDoc.StartEnumeration(pos, _
ListTypeID.unitProc_LID, _
ContainerTypeID.flowsheet_CID, "")
Do While (bContinue)
bContinue = SuperProDoc.GetNextItemName(pos, _
procName, _
ListTypeID.unitProc_LID, _
ContainerTypeID.flowsheet_CID, "")
AllProcNames = allProcNames + CStr(procName) + " "
Loop
End Function
Note that to involve the appropriate enumerator for all unit procedures, we need to understand that the ‘container’ object for this list is the flowsheet (and thus we pass the flowsheet_CID as the value for the ContainerTypeID parameter, see Specifying Container Type). Of course, the ListTypeID (that specifies which type of list we are enumerating, see Specifying Item List Type) is unitProc_LID.
Also note that the call to GetNextItem() will return ‘False’ to indicate that the returned value is the last one in the list, and therefore, the loop needs to terminate. If the list we are enumerating has no members (i.e., it’s empty) then the call to StartEnumeration() will fail.
To see example scripts on how to use the above enumerator functions (in the context of Streams and Material items) please view the ComEx8.xls file in the COM folder located under the "EXAMPLES" folder under your application’s installation directory.