The following VBA code will retrieve from a ProDesigner document the names of all unit procedures in all sections and in all branches in the Process. 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 GetAllUPNames()
Dim bContinue as Boolean
Dim branchName, sectionName, procedureName as Variant
Dim pos as Variant
Dim allUPNames as String
bContinue = SuperProDoc.StartEnumeration(pos, _
ListTypeID.branch_LID, _
ContainerTypeID.flowsheet_CID, _ “”)
Do While (bContinue)
bContinue = SuperProDoc.GetNextItemName(pos, branchName, _
ListTypeID.branch_LID, _
ContainerTypeID.flowsheet_CID, _
“”)
Dim bContinue2 As Boolean
Dim pos2 As Variant
bContinue2 = SuperProDoc.StartEnumeration(pos2, _
ListTypeID.section_LID, _
ContainerTypeID.branch_CID, _
branchName)
Do While (bContinue)
bContinue = SuperProDoc.GetNextItemName(pos2, sectionName, _
ListTypeID.section_LID, _
ContainerTypeID.branch_CID, _
branchName)
Dim bContinue3 As Boolean
Dim pos3 As Variant
bContinue2 = SuperProDoc.StartEnumeration2(pos, _
ListTypeID.unitProc_LID, _
ContainerTypeID.section_CID, _
sectionName, branchName)
Do While (bContinue)
bContinue = SuperProDoc.GetNextItemName2(pos, procedureName, _
ListTypeID.unitProc_LID, _
ContainerTypeID.section_CID, _
sectionName, branchName)
allUPNames = allUPNames + CStr(procedureName) + " "
Loop
Loop
Loop
End Function
Note that to involve the appropriate enumerator for all the unit procedures in a sections in all branches, we need to understand that the ‘container’ object for this list is a section (ContainerTypeID is section_CID, see Specifying Container Type) and is carried out in a specific branch, therefore we must pass as arguments to the functions not only the name of the section <sectionName> but also the name of the branch <branchName>. 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 must terminate. If the list we are enumerating has no members (i.e., it’s empty) then the call to StartEnumeration() will fail.