After you record or write a macro in Excel, you can run the macro, or go slowly through it, line by line, to see if it is working correctly. I use the F8 key, in the Visual Basic Editor, if I’m troubleshooting a macro, to see where something is going wrong. You can use also use the Step Into command, in the VBE’s Debug menu.
在Excel中记录或编写宏之后,您可以运行该宏,或逐行缓慢浏览该宏,以查看其是否正常运行。 如果要对宏进行故障排除,请在Visual Basic编辑器中使用F8键,以查看问题出在哪里。 您还可以使用VBE的“调试”菜单中的“进入”命令。
![f8problemfix04 f8problemfix04](https://i-blog.csdnimg.cn/blog_migrate/425e68098ee05870ecc056a09ca3e731.png)
However, for the past few months, something was going wrong with the “Step Into” command in Excel 2010, whether I used the menu, or the F8 key.
但是,在过去的几个月中,无论我使用菜单还是F8键,Excel 2010中的“逐步进入”命令都出了问题。
代码不会停止 (Code Doesn’t Stop)
In some macros, especially if the code opened another Excel file, when I pressed the F8 key, the code ran to the end of the macro, instead of stopping at the next line of code. That made it very difficult to troubleshoot the code!
在某些宏中,尤其是如果代码打开了另一个Excel文件,当我按F8键时,代码将运行到宏的末尾,而不是在下一行代码处停止。 这使得对代码进行故障排除非常困难!
It could also cause other inconvenient or embarrassing problems, if the macro was designed to update files, or send out emails. You don’t want that kind of thing happening at the wrong time.
如果宏被设计为更新文件或发送电子邮件,它还可能导致其他不便或尴尬的问题。 您不希望这种事情在错误的时间发生。
As a workaround, I could add breakpoints in the code, and it would stop there. Unfortunately, I didn’t always know when the F8 problem might occur, so I didn’t add the breakpoints in every procedure, before trying to step through it.
作为一种解决方法,我可以在代码中添加断点,并且它将在此处停止。 不幸的是,我并不总是知道何时可能发生F8问题,因此在尝试逐步解决问题之前,我没有在每个过程中都添加断点。
I searched Google, to see if anyone had a solution for the “F8 runs to the end of the macro” problem, but couldn’t find anything. There were other people complaining about the same thing, but nothing to fix the problem.
我搜索了Google,看是否有人可以解决“ F8运行到宏末尾”的问题,但找不到任何东西。 还有其他人抱怨同样的事情,但没有解决这个问题的方法。
终于找到了解决方案 (Finally a Solution Found)
Finally, my friend, Ross Connell, found a solution last week, and kindly shared it with me. Ross spent a long time communicating with Microsoft’s tech support, about this and a couple of other issues, and someone there suggested this fix.
最后,我的朋友罗斯·康奈尔(Ross Connell)上周找到了解决方案,并与我分享了该解决方案。 罗斯花了很长时间与Microsoft的技术支持人员就此问题以及其他一些问题进行了交流,有人建议使用此修复程序。
The suggestion is not documented on the Microsoft website though, so don’t take this as an official recommendation from them. However, making this change fixed the problem for me, and for Ross. If you’re comfortable in making a change to your Windows Registry, you can try it too, at your own risk.
但是,该建议未在Microsoft网站上记录,因此请勿将其作为官方建议。 但是,进行此更改对我和罗斯都解决了问题。 如果您愿意对Windows注册表进行更改,也可以尝试尝试,但后果自负。
更改注册表 (Change the Registry)
To fix this problem, you can add a new DWORD in the Registry. It’s easy to do, but as always, when working in the Registry, be careful!
若要解决此问题,您可以在注册表中添加一个新的DWORD。 这很容易做到,但是和往常一样,在注册表中工作时要当心!
I’ve outlined the steps on my website, and you can see the details here. Read the warnings carefully – you can mess things up if you aren’t careful when making a change in the Windows Registry.
我已经在网站上概述了步骤,您可以在此处查看详细信息 。 请仔细阅读警告-如果在Windows注册表中进行更改时不小心,可能会搞砸。
On my computer, I’ve got 32-bit Office installed, on a 64-bit system, and below is a screen shot of the DWORD as I added it.
在我的计算机上,我安装了32位Office,在64位系统上,下面是我添加DWORD的屏幕截图。
If you had the F8 problem, and tried this solution, please let me know your results, in the comments. Thanks!
如果您遇到F8问题,并尝试了此解决方案,请在评论中让我知道您的结果。 谢谢!
![f8problemfix02 f8problemfix02](https://i-blog.csdnimg.cn/blog_migrate/d147c028c8b7dc794b3a3e4d7cfe64db.png)
翻译自: https://contexturesblog.com/archives/2014/09/04/excel-vba-problem-with-step-into-f8/