I have a MS Word template (.dot file), and sometimes the Debug->Compile option is available, and sometimes it isn’t. Why? And why should I want to compile my VBA at all?
I have a MS Word template (.dot file), and sometimes the Debug->Compile option is
Share
If you compile your project (or run a Sub, which automatically compiles the project before running) then the Compile item disappears, since the project is already compiled. As soon as you edit your VBA code, the Compile item will reappear in the Debug menu.
It behaves a bit like the “Save” item in the File menu of some applications e.g. certain text editors. If the file has not changed since it was last saved, then the “Save” item is grayed out.
As for why you would want to compile: it’s a good way to test for compile-time errors, without having your code actually run. If you just run it, then it will compile and then proceed to execute if there are no compile-time errors. You may not want this to happen if e.g. your code sends e-mail around, modifies your document, deletes files, or whatever.