Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stepping Through (F8) Code suddenly executes all code?

Tags:

excel

vba

A Macro that I wrote (on another machine) is suddenly acting strange on my computer. I wrote the code in the Excel 2010 environment and am trying to step through the code in the same.

Everytime I do so, 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 just auotexecutes again.

What gives? I have found no answers on the web... thus my first post on Stackoverflow.

Thanks for any hints! This is making my life difficult.

UPDATE: I have now gone back to the original programming environment and the stepping through the code there is no problem. So it must be something in my Excel settings! I can't figure out what it could possible be though.

like image 257
rohrl77 Avatar asked Jul 20 '12 07:07

rohrl77


People also ask

Does F8 step neatly through the main procedure?

With the subordinate procedures called that way, F8 steps neatly through the main procedure, and each procedure called from within it. Show activity on this post. I have successfully fixed these problems by doing two things: 1.

How to fix the F8 key not working in Excel?

10.Close the Registry, and re-open Excel, where the F8 key should now work correctly, stepping through the code. Show activity on this post. Since you mentioned that the F8 button works as expected at first, most of my thoughts are cleaned from the table.

How can I simulate F8 on a line?

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.

Is there a way to simulate a F8 breakpoint?

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.


2 Answers

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.

like image 107
Englehas Avatar answered Oct 26 '22 13:10

Englehas


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!

like image 21
html_programmer Avatar answered Oct 26 '22 14:10

html_programmer