编辑 Microsoft Office VBA 时,如何禁用弹出的“编译错误”消息?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11560934/
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 13:35:39  来源:igfitidea点击:

When editing Microsoft Office VBA, how can I disable the popup "Compile error" messages?

vbaeditor

提问by Iain S

When you're editing a Microsoft Office VBA macro or function, you will often move your cursor from a line that you haven't finished. For example, to go copy something you want to paste into that line. But, if that partial line isn't syntactically valid, the VBA editor interrupts your work by popping up a "Compile error" message that has to be dismissed.

在编辑 Microsoft Office VBA 宏或函数时,您通常会将光标从尚未完成的行上移开。例如,将要粘贴的内容复制到该行中。但是,如果该部分行在语法上无效,则 VBA 编辑器会弹出一条必须取消的“编译错误”消息,从而中断您的工作。

Is there any way to disable the message box? I find it irritating...

有什么办法可以禁用消息框吗?我觉得很刺激...

(This happens with Excel Visual Basic for Applications, Outlook VBA, Word VBA, etc.)

(这发生在 Excel Visual Basic for Applications、Outlook VBA、Word VBA 等中。)

回答by ray

Do the following in your VBA editor window (entitled "Microsoft Visual Basic for Applications"):

在 VBA 编辑器窗口(标题为“Microsoft Visual Basic for Applications”)中执行以下操作:

Click the menu "Tools" and then "Options".

单击菜单“工具”,然后单击“选项”。

In the Options' "Editor" tab, uncheck the "Auto Syntax Check" box. (See screenshot, below.)

在选项的“编辑器”选项卡中,取消选中“自动语法检查”框。(见下面的截图。)

This change does not make the editor stop compiling in the background and marking syntax errors in red (or whatever formatting is specified in the Options tab "Editor Format").

此更改不会使编辑器停止在后台编译并将语法错误标记为红色(或“选项”选项卡“编辑器格式”中指定的任何格式)。

MS Office programs share this common VBA editor, so if you change an option while editing VBA for Excel then you've changed it for Outlook, Word, etc.

MS Office 程序共享此通用 VBA 编辑器,因此如果您在为 Excel 编辑 VBA 时更改了一个选项,那么您已经为 Outlook、Word 等更改了它。

MS VBA editor's Tools Options dialog box

MS VBA 编辑器的工具选项对话框

回答by Dick Kusleika

In the VBE, Tools - Options - Editor and uncheck Auto Syntax Check. It will turn bad code red, but won't give you the popup.

在 VBE 中,工具 - 选项 - 编辑器并取消选中自动语法检查。它将把坏代码变成红色,但不会给你弹出窗口。