Message 1 of 4
Error only being caught on the first instance in a for loop? VBA

Not applicable
08-24-2017
08:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm having some trouble with an error that is occurring in part of my code. I don't know a great deal about error handling but I can't see why what I have done isn't working.
I'm using a VBA macro to find which faces have threads on, it works for all the threaded faces but produces an error if there isn't a thread there. This is fine as long as the error can be dealt with and doesn't stop the macro.
Here's the main part of the code:
'oAlignedFaceColl is a collection of cylindrical faces
For i = 1 To oAlignedFaceColl.Count
Dim oThreadInfos As ObjectCollection Set oThreadInfos = oAlignedFaceColl(i).ThreadInfos On Error GoTo NextStep Set oThreadInfo = oAlignedFaceColl(i).ThreadInfos(1) Debug.Print Err.Number, "error number" NextStep: Next
The first error that's found does go to the line NextStep however the second time