Reliably Access Sheet Set Components

Sheet Set Manager API

 
Reliably Access Sheet Set Components
 
 
 

You can use the Do While structure in VBA for reliable access to sheet set components. The Microsoft Help for VBA contains examples of the Do While structure. The Microsoft Help for VBA is available from the Help menu in the VBA IDE.

To use the Do While structure to access sheet set components, you use a statement similar to Do While Not obj Is Nothing to determine if an object is available. For example, to use a Do While Not obj Is Nothing statement to iterate through objects in a collection, you could use the following code:

Public Function FindAllComponents(comps As Collection) As Boolean
 On Local Error GoTo etrap
 If comps Is Nothing Then Set comps = New Collection
 Dim iter As IAcSmEnumPersist
 Set iter = m_db.GetEnumerator
 Dim obj As IAcSmPersist
 Set obj = iter.Next
 Do While Not obj Is Nothing
 If TypeOf obj Is IAcSmComponent Then
 Dim comp As IAcSmComponent
 Set comp = obj
 comps.Add comp
 End If
 Set obj = iter.Next
 Loop
 FindAllComponents = True
 Exit Function
etrap:
 MsgBox CStr(Err.Number) & " - " & Err.Description
End Function

For an additional example of using the Do While structure in VBA to access sheet set components, see the sample VBA project in the Sample\ActiveX\SheetSetVBA directory of your AutoCAD installation.