By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,483 Members | 1,464 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,483 IT Pros & Developers. It's quick & easy.

Excel Automation debug issue

TheSmileyCoder
Expert Mod 100+
P: 2,321
I this piece of code in excel:
Expand|Select|Wrap|Line Numbers
  1. With wrkSheet.Range("A" & intL, "G" & intL)
  2.   .Merge
  3.   .Value = rsGroup!tx_GroupTitle
  4.   .Font.Name = "Calibri"
  5.   .Font.Bold = True
  6.   .font.Size = 11
  7. End With
It is part of a do loop, where intL keeps track of the line number I have reached, and I have set a breakpoint at the beginning of the loop, and I am now stepping through the code using F8. When line 3 is executed, it can best be described as if VBE believes I have pressed F5 instead of F8, the code runs until the next breakpoint.

I know that the code lines 4 and 5 and so on are executed, and I know that no error is thrown. If I put a breakpoint on line 4 VBE will stop and break.

Has anyone else ever encountered such an issue?
Apr 19 '12 #1

✓ answered by NeoPa

Just read it Smiley. This happens sometimes when Excel determines that it cannot use the stepping feature (or that same feature fails for some reason).

Share this Question
Share on Google+
5 Replies


NeoPa
Expert Mod 15k+
P: 31,186
Just read it Smiley. This happens sometimes when Excel determines that it cannot use the stepping feature (or that same feature fails for some reason).
Apr 19 '12 #2

TheSmileyCoder
Expert Mod 100+
P: 2,321
Thank you. Do you have a link to some official source? I did find some vaguely related posts, but nothing with a more detailed explanation.
Apr 20 '12 #3

NeoPa
Expert Mod 15k+
P: 31,186
Sorry no. I just experienced it a few times over the years.

In real code it's easier to understand, as the intel processors are all based on the same basic architecture and stepping through (processor-level) code is handled by a hardware interrupt being dedicated to that specific feature. If ever something interfered with the interrupt table in RAM (as some code would, particularly when trying to avoid anyone determining what it was doing) then the step-through interrupt would fire, but divert the thread of the code to somewhere undefined and everything went belly-up.

I doubt that a debugger for semi-compiled code could possibly work in the same way though, in as much as a line of VBA code could hardly ever relate to a single processor instruction. My guess is that a more standard breakpoint (another processor interrup) is used and is placed at the point (or points) where that line would finish at. I have no hypothesis as to why that might result in the behaviour you've seen, but it's as far as I ever got I'm afraid. It could simply be a fault in the logic of the debugger that's never been identified and fixed (for all I know).
Apr 20 '12 #4

TheSmileyCoder
Expert Mod 100+
P: 2,321
Thank you again. The first time I saw it, I kept thinking the code exited or errored or something. Took me a while to track down the issue, to the Step-Through not working as expected.

I should probably have mentioned this is happening to me in Office 2010 on windows 7, but from what I hear from you, it has happened to you on earlier platforms as well.

Have you ever experienced it when running directly from excel (or another office application) and not when using automation?
Apr 20 '12 #5

NeoPa
Expert Mod 15k+
P: 31,186
To be honest it's so long now since I remember it happening that I can't say for sure, though that long ago I wasn't doing much automation. I had a short spell using it in 1999, then didn't need it again until someone asked about it on Bytes in the later noughties. Then I genned back up on it and now I use it whenever it presents itself as a sensible solution.
Apr 20 '12 #6

Post your reply

Sign in to post your reply or Sign up for a free account.