Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
It's almost as if the VBA editor inside Inventor doesn't know what a Try/Catch is. Here's my code:
Sub HideBreakRepresentationsInDrawing() If ThisApplication.Documents.Count <> 0 Then Dim Doc As DrawingDocument Set Doc = ThisApplication.ActiveDocument Else Call MsgBox("No open documents") Exit Sub End If Dim Sheets As Sheets Set Sheets = Doc.Sheets 'recurse all sheets in drawing document Dim Sheet As Sheet For Each Sheet In Sheets Dim Views As DrawingViews Set Views = Sheet.DrawingViews 'recurse all drawing views in sheet Dim View As DrawingView For Each View In Views 'assumes the drawing view references an assembly Try Dim RefDoc As AssemblyDocument Set RefDoc = View.ReferencedDocumentDescriptor.ReferencedDocument 'run-time error 13: mismatch 'recurse all components in assembly referenced by view Call recurseOccurrences(RefDoc.ComponentDefinition.Occurrences) End Try Next Next End Sub
I'm trying to except the times when RefDoc is not an assembly document. In those cases, I just want to move to the next iteration of the For loop. The "End Try" line is red and gives the compile error when I write it, then when I run the script I get "Sub or Function not defined" on the Try line. What am I doing wrong?
Solved! Go to Solution.