158

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.

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.)

Jon Freed
  • 156
  • 12
Iain S
  • 2,643
  • 3
  • 23
  • 23

2 Answers2

223

Do the following in your VBA editor window (entitled "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 VBA editor's Tools Options dialog box

Jon Freed
  • 156
  • 12
ray
  • 8,521
  • 7
  • 44
  • 58
  • 5
    Just FYI. This didn't work for me until I restarted Excel 2010 – DontFretBrett Apr 10 '13 at 01:17
  • 42
    It's also worth mentioning that even with the above box unticked, syntax errors ARE still marked in red...which is useful! – Jonny Aug 08 '14 at 11:52
  • 2
    This also works for the VB6 IDE (I know, I know, it's 2015... but legacy code still needs updating occasionally) – Cemafor Jan 12 '15 at 21:13
  • 13
    Programming is seldom linear. Why the f*** did Microsoft set Auto Syntax Check as default? – Holene Oct 01 '15 at 12:11
  • 6
    OMG Thank you. I formatted, reinstalled, and I was ready to smash something if I didn't get that figured out soon. ***"Ding!"*** *...Yes, VBA, I **realize** I moved to a different line to copy something for this line."* – ashleedawg May 09 '18 at 10:03
  • 1
    I wasn't looking for this, never thought about searching for it, but I'm really glad that I found it. That popup message is definitely annoying. Only marking the code red is enough since the code gets edited a lot when creating it and it doesn't always come out free of syntax errors when typing it for the first time(s) and changing lines. – user7393973 May 28 '19 at 08:26
  • 1
    This is still a valid solution when using Microsoft Office 365 products. Poor name for this "feature"... – Chris Collett Jan 07 '21 at 22:30
  • 1
    VBA is for ideal programmers… ones who write correct code from the first run! Ah, one can only envy such programmers. – AKd Jan 24 '23 at 06:11
  • Wow, after four years i'll never have to deal with 5 pop-ups while creating a SQL statement. Thank you – daveyvdweide Aug 08 '23 at 19:53
29

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

Dick Kusleika
  • 32,673
  • 4
  • 52
  • 73