8

I wrote code in an Excel 2010 environment and am trying to step through the code in the same.

After a few lines, the rest of the code is immediately executed. If I set a breakpoint it will stop. Sometimes, I can then step through a few more lines before it auotexecutes again.

I have gone back to the original programming environment and stepping through the code there is no problem.

Community
  • 1
  • 1
rohrl77
  • 3,277
  • 11
  • 47
  • 73
  • Weird - Have you tried to compile the code before debugging it on the machine where you have the issue? (Not sure it would do anything but worth trying) – assylias Jul 20 '12 at 10:28
  • 1
    Hi Assylias, tried your suggestion and learned how to compile VBA code (at least in Excel), but no go... still the same issue. – rohrl77 Jul 20 '12 at 11:04

9 Answers9

6

I found this solution also referenced here. The solution is to make a change to the registry (taken from the source):

The registry change affects RPC Debugging, and you can read more about it on the Microsoft website: Debugging COM Clients and Servers Using RPC Debugging

1.Close Excel

2.Make a backup of the Registry file, then open the Registry -- there are instructions on the Microsoft website

3.Go to the applicable Registry Key:

  • For 32-bit Office on 64-bit Window go to registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VBA
  • For 32-bit Office on 32-bit Window go to registry key: KEY_LOCAL_MACHINE\SOFTWARE\ Microsoft\VBA
  • For 64-bit Office on 64-bit Windows go to registry key: KEY_LOCAL_MACHINE\SOFTWARE\ Microsoft\VBA

4.Right-click in the window at the right, and click New

5.Click DWORD (In the screen shot below, the DWORD is for 32-bit Office running on a 64-bit computer)

6.Name the DWORD as DisableOrpcDebugging7

7.Right-click the DWORD, and click Modify

8.Change Value to 1, and click OK.

9.The completed DWORD will appear in the Registry

10.Close the Registry, and re-open Excel, where the F8 key should now work correctly, stepping through the code.

Englehas
  • 308
  • 4
  • 9
  • While in my case removing the Installed Application solved the issue at the time, I have also experienced the issue later in other instances with Excel 2010. I think Debra's Answer and also yours are probably correct. I will implement the next time I get the chance. Thanks for the update! – rohrl77 Jan 05 '16 at 07:42
5

Since you mentioned that the F8 button works as expected at first, most of my thoughts are cleaned from the table.
I cannot explain this, but perhaps I can provide a temporary "workaround", which is the best I can do.
You can simulate F8 by clicking each line followed by applying CTRL+F8 (Run to cursor). The cursor will act as a breakpoint and it is less bothersome than placing / removing breaks on each and every line.
It is a little bit more handwork, but it goes as fast (at least on a regular desktop). Hope it can at least reduce some of your frustration when debugging!

html_programmer
  • 18,126
  • 18
  • 85
  • 158
2

FINAL UPDATE: It turns out that another application which I had running the background, called KeyRocket, and which is designed to help you memorize keyboard shortcuts in office applications, was responsible for the screwy behavior. I hope this helps someone else!

And finally thanks to everyone for their suggestions!

rohrl77
  • 3,277
  • 11
  • 47
  • 73
  • If you give KeyRocket access to the VBA model in Excel Trust settings this will work http://veodin.uservoice.com/knowledgebase/articles/494702 – Cilvic Jan 30 '15 at 14:10
2

I had a similar issue, but closed excel down and saw there was a EXCEL.EXE *32 process still running, killed that, then reopened and ran macro again. could not reporduce and macro stepped though as expected.

HattrickNZ
  • 4,373
  • 15
  • 54
  • 98
2

I had the same issue, however in Word (not Excel) 2010.

I tried the various things mentioned by other contributors above, e.g. closing other programmes that might utilise the F8 key for something, and closing other MS Office 2010 applications that might interfere, however, the issue was stubbornly there: from a certain point of my VBA code, the step-by-step execution of the code (F8 key) was ignored, and the entire procedure was executed at once.

I then made a number of experiments with my code. Thus I found: in my case, the unwanted behaviour appeared right when I called an external procedure as follows:

Application.Run MacroName:="OneProcedureOfMine"

To circumvent the issue, I rewrote the code just like so:

Call OneProcedureOfMine

which is anyway the more elegant way. And it solved the problem. With the subordinate procedures called that way, F8 steps neatly through the main procedure, and each procedure called from within it.

  • Hi Christian, interesting comment. I still deal with this problem occasionally and have noticed that it also happens for example after I call a MsgBox. After I klick OK", the code auto executes. Do you happen to know if this also happens in Word? If it does, then I think it is some sort of bug in VBA. – rohrl77 Aug 10 '15 at 06:35
  • At the moment, I have no clear observation of such a case (step-by-step execution [F8 key] being ingored after a MsgBox). But what you write sounds somehow familiar to me... as soon as I am faced with such a situation (again) I will investigate it and post the results. – Christian Geiselmann Aug 10 '15 at 10:20
1

I have successfully fixed these problems by doing two things: 1. If you have more than one Keyboard driver loaded, removed the one you are not using 2. If your keyboard has a "F Lock" key (located to the right of F12 on my Keyboard), press it and try again.

1

I know this is a very old thread, but I just found it. I check the task manager and found that I had a "stuck" Access process running. I got rid of that and everything works find now.

C Suttle
  • 51
  • 3
1

I faced the same issue. I created a new module and pasted my code into this new module and it Worked!! Hope it helps if someone is facing the same issue.

SenthamilVM
  • 93
  • 1
  • 3
  • 13
1

Registry related solution, saying QWORD should be used in a 64-64 combo, didn't work.

I went for DWORD, which solved it.

Community
  • 1
  • 1
  • This gives the impression of basically saying "thanks" for https://stackoverflow.com/a/34533958/7733418 . If you mean this to contribute any additional insight please [edit] to make that more obvious, ideally according to [answer]. A simple thanks is not considered an answer and should be deleted. – Yunnosch Sep 25 '22 at 20:18