当键盘上没有中断键时,excel VBA 中断执行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10114447/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 12:55:17  来源:igfitidea点击:

excel VBA break execution when there's no break key on keyboard

excelvbaexcel-vbakeyboard

提问by frenchie

I'm just noticing that on my laptop (Dell XPS 15z) there's no BREAK key (no dedicated number keypad). I'm running the debugger step-by-step and then when all seems fine, I just let it play out. However, it's running in an infinite loop and now I'm realizing there's no way to stop it without the break key!!!!

我只是注意到在我的笔记本电脑(戴尔 XPS 15z)上没有 BREAK 键(没有专用的数字键盘)。我正在逐步运行调试器,然后当一切正常时,我就让它发挥作用。然而,它在无限循环中运行,现在我意识到没有 break 键就无法停止它!!!!

Is this a bad joke? I had to reboot the computer; is there a more graceful way??

这是一个坏笑话吗?我不得不重新启动计算机;有没有更优雅的方式??

Thanks.

谢谢。

采纳答案by Ben Strombeck

just press the escape key twice ;-)

只需按两次退出键 ;-)

回答by jainashish

Solution #1 (It works most of the time):When some particular keys (Pause, Breakor ScrLk)are missing on the keyboard and pressing Esc2, 3 or multiple times doesn't stop the macro too.

解决方案#1(大部分时间都有效):当某些特定键(Pause,BreakScrLk)键盘上缺少某些键时,按Esc2、3 或多次也不会停止宏。

Step #01: If your keyboard does not have a specific key, please do not worry and open the 'OnScreen Keyboard' from Windows Utilities by pressing Win+ U.

步骤 #01:如果您的键盘没有特定键,请不要担心,然后按Win+从 Windows 实用程序打开“屏幕键盘” U

Step #02: Now, try any of the below option and of them will definitely work depending on your system architecture i.e. OS and Office version

步骤 #02:现在,尝试以下任何选项,根据您的系统架构,即操作系统和 Office 版本,它们肯定会起作用

  • Ctrl+ Pause
  • Ctrl+ ScrLk
  • Esc+ Esc(Press twice consecutively)
  • Ctrl+ Pause
  • Ctrl+ ScrLk
  • Esc+ Esc(连续按两次)

You will be put into break mode using the above key combinations as the macro suspends execution immediately finishing the current task. For eg. if it is pulling the data from the web then it will halt immediately before executing any next command but after pulling the data, following which one can press F5or F8to continue the debugging.

您将使用上述组合键进入中断模式,因为宏会立即暂停执行以完成当前任务。例如。如果它正在从网络上拉取数据,那么它会在执行任何下一个命令之前立即停止,但在拉取数据后,可以按F5F8继续调试。



When Solution #1 doesn't work or you need a permanent solution then try adding a new KEY to the Registry. (I am running Win 10 Creators Update on Dell 3530 Inspiron Laptop)

当解决方案 #1 不起作用或您需要一个永久的解决方案时,请尝试向注册表添加一个新的 KEY。(我在戴尔 3530 Inspiron 笔记本电脑上运行 Win 10 Creators Update)

Disclaimer: Please only make changes to Windows Registry at your own risk and it is advisable only if you are windows administrator or have prior experience in the changing the key values in the registry.

免责声明:请仅在您自己承担风险的情况下更改 Windows 注册表,并且仅当您是 Windows 管理员或具有更改注册表中键值的经验时才建议这样做。

You can also look for Solution #2 which use accessibility keyboard Win+ U

您还可以查找使用辅助功能键盘Win+ 的解决方案 #2U

Solution #2:1) Click the START, then type REGEDIT into the search box. This will start the registry editor.

解决方案#2:1) 单击开始,然后在搜索框中键入 REGEDIT。这将启动注册表编辑器。

2) Explore the Registry, expanding each element HKEY_LOCAL_MACHINE -SYSTEM -Current Control Set - Control - Keyboard Layout

2)探索注册表,展开每个元素 HKEY_LOCAL_MACHINE -SYSTEM -Current Control Set - Control - Keyboard Layout

Click on the Scancode Map, and EDIT the key values to match that shown below. i.e. to have values of : 00,00,00,00,00,00,00,00,02,00,00,00,46,e0,44,00,00,00,00,00

单击 Scancode Map,然后编辑键值以匹配下面显示的值。即有值:00,00,00,00,00,00,00,00,02,00,00,00,46,e0,44,00,00,00,00,00

Once Done you will need to reboot your laptop, but after that, you can use as the pause/Break Key.

完成后,您将需要重新启动笔记本电脑,但之后,您可以将其用作暂停/中断键。

To understand it in detail and customize it as per your needs, please refer this link: KeyBoard Scancodes

要详细了解它并根据您的需要对其进行自定义,请参阅此链接:KeyBoard Scancodes

回答by LiamH

Despite this being an old question, I have just encountered the same issue and discovered that Ctrl+Scroll lockworks as a break.

尽管这是一个老问题,但我刚刚遇到了同样的问题并发现它Ctrl+Scroll lock可以作为休息。

"Scroll lock" can be accessed on my DELL Laptop via the blue function key "Fn" and the "F6" key which has a small blue lock symbol on it with an ? symbol in it. At other computers it may look like ? . So effectively I press Ctrl+Fn+F6.

可以通过蓝色功能键“Fn”和“F6”键在我的戴尔笔记本电脑上访问“滚动锁定”,该键上有一个带有 ? 其中的符号。在其他计算机上它可能看起来像?. 如此有效地我按 Ctrl+Fn+F6。

回答by Clopes

I have a Dell Precision without a Pause/Breakkey but there is a replacement for that: Fn + B, so:

- Fn+ B== Pause(pause execution);
- Ctrl+ Fn+ B== Break(break execution);
- Win+ Fn+ B== Windows+ Pause(open System properties).

我有一个没有Pause/Break键的 Dell Precision,但有一个替代品:Fn + B,所以:

- Fn+ B== Pause(暂停执行);
- Ctrl+ Fn+ B== Break(中断执行);
- Win+ Fn+ B== Windows+ Pause(打开系统属性)。

You can execute the command:

您可以执行以下命令:

dir /s C:\

and test the Pause and Break combination keys while dir lists all files in drive C.

并测试 Pause 和 Break 组合键,同时 dir 列出驱动器 C 中的所有文件。

reference

参考

回答by Bob

I have an HP laptop and this works when I want to break after a msgbox, hold fn+ctrl and click right shift key (has pause on it as well) then respond to msgbox and code will break.

我有一台 HP 笔记本电脑,当我想在 msgbox 后中断时,这可以工作,按住 fn+ctrl 并单击右移键(也有暂停)然后响应 msgbox 并且代码将中断。

回答by someguy

On my Dell at least : ctrl + alt + esc BEFORE your cursor starts looping itself

至少在我的戴尔上:ctrl + alt + esc 在光标开始循环之前

I got this info from aidangrogan on this website :

我从这个网站上的 aidangrogan 那里得到了这个信息:

http://en.community.dell.com/support-forums/laptop/f/3518/t/19355018

http://en.community.dell.com/support-forums/laptop/f/3518/t/19355018

So I don't claim to have found it myself. All credits to him (or her)

所以我并没有声称自己找到了它。他(或她)的所有功劳

回答by Monkey

Hold CTRL+Fn& hit Shift- Stopped my macro from running. I don't have a 'Break' key either on the keyboard of my HP Pavilion G7.

Hold CTRL+ Fn& hit Shift- 停止运行我的宏。我的 HP Pavilion G7 的键盘上也没有“Break”键。

回答by mohitmendon

I have a Japanese Layout keyboard. I neither have a scroll lock nor a break on my laptop-Lenovo E470. A long press on the Esckey worked as a terminator for me.

我有一个日语布局键盘。我的笔记本电脑联想 E470 既没有滚动锁也没有中断。长按Esc键对我来说就像一个终结者。

回答by sdschaber

Ctrl+ Fn+ Bworks for Excel 365 (Office 365) on my Dell Latitude 5480 (no Breakkey).

Ctrl+ Fn+B适用于我的戴尔 Latitude 5480(无Break键)上的 Excel 365 (Office 365 )。

回答by DriveThomas

None of the above answers work for me.

以上答案都不适合我。

I did how ever find this, it's not perfect since you need to keep ALTpressed and then a keys twice. On top of that it's depended on what language your Excel is set to.

我是怎么找到这个的,它并不完美,因为你需要ALT按住两次,然后再按一次键。最重要的是,这取决于您的 Excel 设置的语言。

In an English Excel you'd use ALT+ R+ Rin German you need to use ALT+ U+ R

在英语Excel中你会使用ALT+ R+R在德国,你需要使用ALT+ U+R