title: VBA Workbooks stop working with upgrade to Excel 365 - VBA Compiling Issue?
body: <p>Since upgrading to Excel 365, my company has been having all sorts of trouble with VBA-supported Excel workbooks crashing or not functioning properly. The issues have popped up in various workbooks and various departments, including seemingly simple VBA workbooks. I've discovered a fix (see below) but it's not sustainable.</p>
  <p><strong>The Issues</strong></p>
  <p>The various issues we have experienced are listed below. Note, these issues only occur when you open a file in Excel 365 desktop. The same files, when opened in the Excel 365 browser app or in Excel 2016 will work fine. Also, all these issues happen at random. A user may have been working in a file for weeks and then the next time they open the file they get one of these errors.</p>
  <ul>
  <li>&quot;Can't find project or library&quot; errors even when we are using the standard set of libraries and basic VBA. Then when you open the VBA Editor window, all the VBA screens are essentially frozen up and the library list is inaccessible.</li>
  <li>Excel hard crashes or locks up when opening these files and enabling VBA. Note, the crash only occurs when the VBA is enabled. If you open a file without enabling VBA, it will work fine (though obviously you can't use any of the code).</li>
  <li>The file opens seemingly fine, but the VBA doesn't work and once again, everything is locked up when you access the VBA editor window.</li>
  <li>&quot;unhandled win32 exception occurred&quot; error</li>
  <li>when executing a command, getting an error 32809 which seems to indicate the compiled VBA has been corrupted</li>
  </ul>
  <p><strong>The Fix</strong></p>
  <p>Opening the VBA Editor window, then selecting Debug -&gt; Compile VBAProject  seemingly fixes the issue. I've yet to experience any of the above issues where the file had been manually compiled this way. The problem with this is that every time you add code to a file or any time you add a new tab to a file, you have to go in and perform this manual compile again.</p>
  <p>Yes, apparently adding a single tab in a file changes the workbook structure enough that it is necessary to compile again. The Compiled VBAProject selection will be greyed out. But adding a tab (or adding new VBA) will un-grey it and require another manual compile or the problems start occurring again.</p>
  <p>This fix also works to repair files where the above issues are occurring. To fix those files, you can:</p>
  <ol>
  <li>Make sure &quot;Disable Trusted Documents&quot; and &quot;Disable VBA macros with notification&quot; are toggled on in your security settings so that VBA doesn't automatically run when you open a file.</li>
  <li>Open the file with the errors but do not enable the VBA.</li>
  <li>Go to the VBA Editor window, select Debug -&gt; Compile VBAProject.</li>
  <li>Save the file, close it, reopen it, enable the VBA, and everything works fine again.</li>
  </ol>
  <p>But again, this isn't sustainable because all my users will have to remember to go compile VBA any time they add a new tab to a workbook.</p>
  <p><strong>Help?</strong></p>
  <p>Has anyone found a more sustainable fix to this issue? Is there a bug with the Excel 365 Desktop automatic compiler that Microsoft is working on?</p>