There are certain errors that I raise within my validation routine that I
handle differently depending on what the calling procedure is. Becasue of
this, I handle these errors in their respective calling procedures. To do
this, I use the Err.Raise method inside my validation routine to send the
error back up to the calling proc. Since this validation routine is inside
a class module, it halts execution when it reaches an Err.Raise within an
error handler (because error handling is set to "Break in Class Module" by
default). When the error trapping behavior of VB is set to "Break on
Unhandled Errors", the error is correctly sent back to the calling routine
where it is dealt with properly.
Whenever VBA is initialized, the error trapping behavior of VB is set to
"Break in Class Module". I need a way to set the error trapping to "Break
on Unhandled Errors" either through code or some other way. Otherwise, each
time VBA is initialized, the VB Editor has to be opened and error trapping
manually set.
Sorry for the confusion...
Jeff
Bill Daly wrote in message
news:893mts$klf17@adesknews2.autodesk.com...
> Try putting something like
> Debug.Assert False
>
> just after
> Msgbox Err.Description
>
> You can force a breakpoint this way that will survive closing the project
> and all references to Debug are automatically removed when the project is
> compiled.
> --Bill
>
> Jeff Uhlir wrote in message <893en5$klf6@adesknews2.autodesk.com>...
> >Thanks Eric,
> >
> >I acutally take things a step further by raising errors in my error
> handlers
> >so that they can get handled in the calling procedure. This way I can
> >handle all of my application-specific errors in one routine. I do
> something
> >like this:
> >
> >Private Sub ChildProc
> > On Error GoTo ErrHandler
> >
> > If then
> > Err.Raise ERR_NUMBER,"ChildProc",ERR_DESCRIPTION
> > End If
> >
> >Exit_ChildProc:
> > Exit Sub
> >
> >ErrHandler:
> > With Err
> > If .Number = ERR_NUMBER Then
> > .Raise .Number, .Source, .Description
> > Else
> > Msgbox Err.Description
> > End If
> > Exit With
> > Resume Exit_ChildProc
> >Exit Sub
> >
> >When error trapping is set to "Break on Unhandled Errors", this works
fine.
> >However, every time VBA is initialized, error trapping goes back to the
> >"Break in Class Module" setting. When in this default setting, errors
> >raised in error handlers get treated like a regular run time error
> >(application crash).
> >
> >If anyone knows how I can set the default error trapping
> >(Options/Tools/General Tab) to "Break on Unhandled Errors", I would
greatly
> >appreciate it. Thanks
> >
> >Jeff
> >
> >eric wrote in message
> >news:8927g5$i216@adesknews2.autodesk.com...
> >> Try something like this
> >>
> >> Sub LayerToggle()
> >> Dim currLayer As AcadLayer
> >> Dim newlayer As AcadLayer
> >> Dim lNameLength As Long
> >> Dim sName As String
> >> Dim sRtName As String
> >>
> >> On Error GoTo Err_LayerToggle
> >>
> >> [notice the above always occurs prior to the real code]
> >> [notice below normally occurs after the real code]
> >>
> >> Exit_LayerToggle:
> >> ' Clears memory for use by other programs
> >> Set currLayer = Nothing
> >> Set newlayer = Nothing
> >> Exit Sub
> >>
> >> Err_LayerToggle:
> >> MsgBox Err.Description
> >> Resume Exit_LayerToggle
> >>
> >> End Sub
> >>
> >> The above is basic error trapping, I do this in every routine I write.
> >>
> >> Good luck,
> >>
> >> Eric
> >>
> >> Jeff Uhlir wrote in message
> >> news:8920jr$fep61@adesknews2.autodesk.com...
> >> > Is there a way I can set my project's error trapping to break on
> >unhandled
> >> > errors without actually going into the tools/options menu in the
> editor?
> >> > Since VBA defaults to break in the class module, whenever I try to
> raise
> >> an
> >> > error, my macro crashes at that point instead of going up the call
> >stack.
> >> > Thanks,
> >> >
> >> > Jeff
> >> >
> >> >
> >>
> >>
> >
> >
>
>