Home All Groups Group Topic Archive Search About
Author
10 Jun 2009 11:01 PM
greg
I have a vba question.
I know this is a vb forum.
But I thought I would post over here and see if I can get some advice over
here.

I have vba code that always breaks on one specific line.  Even without a
break point on the line.
I have an "on error goto" statment in the sub.
I have break on unhandled errors set in the tools > options.
With an on error goto statment could a program still break on a line?

The sub is this.  and breaks on the "For iMainLoop "

thanks for any help

----------------------------------
Sub LoadJoinedTable()
On Error GoTo PlannerError

    Dim JoinedTable As Range
    Dim iMainLoop As Integer

    Dim objWS As Worksheet
    Set objWS = Worksheets(WKSHT_JOINED_TABLE)

    Set JoinedTable = objWS.Range(RANGE_JT_JOINED_TABLE)
    objWS.Range(RANGE_JT_JOINED_TABLE).Worksheet.Activate

    For iMainLoop = 1 To JoinedTable.Rows.Count
-------------------------------------

Author
11 Jun 2009 12:04 AM
MikeD
Show quote Hide quote
"greg" <iu***@ghfhg.com> wrote in message
news:%23fVl19h6JHA.1424@TK2MSFTNGP02.phx.gbl...
>I have a vba question.
> I know this is a vb forum.
> But I thought I would post over here and see if I can get some advice over
> here.
>
> I have vba code that always breaks on one specific line.  Even without a
> break point on the line.
> I have an "on error goto" statment in the sub.
> I have break on unhandled errors set in the tools > options.
> With an on error goto statment could a program still break on a line?
>
> The sub is this.  and breaks on the "For iMainLoop "
>
> thanks for any help
>
> ----------------------------------
> Sub LoadJoinedTable()
> On Error GoTo PlannerError
>
>    Dim JoinedTable As Range
>    Dim iMainLoop As Integer
>
>    Dim objWS As Worksheet
>    Set objWS = Worksheets(WKSHT_JOINED_TABLE)
>
>    Set JoinedTable = objWS.Range(RANGE_JT_JOINED_TABLE)
>    objWS.Range(RANGE_JT_JOINED_TABLE).Worksheet.Activate
>
>    For iMainLoop = 1 To JoinedTable.Rows.Count
> -------------------------------------

I've had that happen a few times in VBA in MS Dynamics GP. You're apparently
using Excel. It's as if VBA "saves" the breakpoint and for whatever reason,
it remains saved even after you've removed the breakpoint. So, every time
execution reaches the line of code where you once had the breakpoint, VBA
enters into break mode.  Even closing the application and restarting it does
not solve the problem.

Sometimes, setting a breakpoint on that line of code, compiling (such as it
is in VBA), saving your VBA project, removing the breakpoint, and again
compiling and saving will fix it. But just as often, that doesn't work. In
those cases, try "re-loading" the code.  By this I mean delete the entire
procedure, compile and save, close the application hosting your VBA project,
restart the application, and re-add your VBA procedure. Depending on the
hosting application, there may be other ways to do this.  For example, with
Dynamics GP (in which I've encountered this the most), VBA customizations
are usually exported into what's called a Package and you simply re-import
the package into Dynamics GP.

However, I think you're much better off asking this in a VBA or Excel
newsgroup because it certainly is not applicable to Visual Basic. But give
the above a try.  Hopefully, it will work for you. You might also search
google or other search engine.  I believe I had done that a couple years ago
and did find some information about it.

--
Mike
Author
11 Jun 2009 10:38 AM
Nobody
"MikeD" <nob***@nowhere.edu> wrote in message
news:uTY4wgi6JHA.4404@TK2MSFTNGP04.phx.gbl...
> I've had that happen a few times in VBA in MS Dynamics GP. You're
> apparently using Excel. It's as if VBA "saves" the breakpoint and for
> whatever reason, it remains saved even after you've removed the
> breakpoint. So, every time execution reaches the line of code where you
> once had the breakpoint, VBA enters into break mode.  Even closing the
> application and restarting it does not solve the problem.

VBA in Office 2002(XP) has "Clear All Breakpoints(Ctrl+Shift+F9)", so this
might work if available, or perhaps the keyboard shortcut.