While I'm not familiar with this ssm method, you can improve your troubleshooting odds by using a structured error handler. It's a misconception that On Error Resume Next only applies to the following line. It stays in effect until you issue On Error GoTo 0. Thus, you didn't need to use it twice. It also, masks valid errors, making them unhandled and crashing your app without warning. Notice the commented out section of the err handler. The first time running this where an error occurs, the logic will fall through to the Case Else and display the error in the MsgBox. Use this to modify the first select case and add the logic to properly handle the error. Run it again and handle any other errors that show up. This will at least tell you why acad is crashing.
Public Sub Test()
On Error GoTo Err_Control
Dim ssm As New AcSmSheetSetMgr
Dim db As New AcSmDatabase
Dim str1 As String
str1 = "H:\2018\Sheet set\Sheet Design 2.dst"
Set db = ssm.OpenDatabase(str1)
Dim dbEnum As IAcSmEnumPersist
Set dbEnum = db.GetEnumerator
Dim item As IAcSmPersist
Set item = dbEnum.Next
Dim shEnum As IAcSmEnumComponent
Dim csPr As AcSmSheetSet
Dim shValue As IAcSmComponent
Dim objs() As Object
Dim retObjs As Object
'On Error Resume Next
While Not item Is Nothing
If item.GetTypeName = "AcSmSheetSet" Then
Set csPr = item
Set shEnum = csPr.GetSheetEnumerator
Set shValue = shEnum.Next
While Not shValue Is Nothing
'On Error Resume Next
Set retObjs = shValue.GetDirectlyOwnedObjects(objs)
Set shValue = shEnum.Next
Wend
End If
Set item = dbEnum.Next
Wend
Exit_Here:
Exit Sub
Err_Control:
Select Case Err.Number
'Add your Case selections here
'Case Is = 1000
'Handle error
'Err.Clear
'Resume Exit_Here
Case Else
MsgBox Err.Number & ", " & Err.Description, , "Test"
Err.Clear
Resume Exit_Here
End Select
End Sub
Ed
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to
post your code.