title: A Way to Automate the "Compile" Function of MS Office's VBA Code
body: <p>Typically when I make a change to a VBA file I like to compile it to ensure my changes didn't break anything:</p>
  
  <p><a href="https://i.stack.imgur.com/e3FKY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/e3FKY.png" alt="enter image description here"></a></p>
  
  <p>But compiling on different machines with different versions of the office will result in different results, sometimes it will compile, sometimes not... Things <a href="https://stackoverflow.com/questions/16763147/excel-vba-code-compile-error-in-x64-version-ptrsafe-attribute-required">like this</a> can happen, or <a href="https://answers.microsoft.com/en-us/msoffice/forum/all/vba-code-works-in-excel-2010-but-not-in-excel-2016/4250dfc2-f52f-4251-9ab7-e87dbe2f24d1" rel="noreferrer">maybe this</a>. Turns out in each version of excel all sorts of <a href="https://stackoverflow.com/questions/24319097/macro-handling-difference-between-ms-excel-2010-and-ms-excel-2013">things can be different</a> (not just references though that is the most common issue).</p>
  
  <p>How would I automate the compiling of my VBA code? I would like to be able to do this in multiple products such as Excel, PowerPoint, and Word, I would like to be able compile as 32 and 64 bit, with 2010, 2013, 2016, etc... </p>
  
  <h2>Update 1</h2>
  
  <p>Yes this is still a major pain point, right now I have a series of manual testers (people) review all relevant files on various different configurations based on our release schedule, there has <strong>got to be a better way</strong> to do this. </p>
  
  <p>What I would prefer is some sort of PowerShell script/.Net project(<a href="https://stackoverflow.com/q/49286336/2912011">C#</a>, VB.NET) that would accomplish this, even if I had to setup a server with a bunch of versions of office, I think it would be well worth the investment.</p>
  
  <p>I'd imagine, worst case you could install all of these different versions onto various VM's, then use <a href="https://www.autohotkey.com/" rel="noreferrer">AutoHotKey</a> plus some sort of PowerShell script to compile them. Macro's on top of Macro's fun... </p>
  
  <p>This odyssey just underlines to me how difficult VBA development is. Am I really the first person to have issues between different versions of excel? Is it unreasonable to ask to be able to <a href="https://developer.android.com/training/multiple-apks/api" rel="noreferrer">compile under different versions</a>? </p>
  
  <p>MS <a href="https://www.reddit.com/r/IAmA/comments/5dgrf8/we_are_the_microsoft_excel_team_ask_us_anything/db8x85f?utm_source=share&amp;utm_medium=web2x" rel="noreferrer">may love it</a>, but to me it's almost like this language doesn't really have a <a href="https://www.quora.com/How-is-the-future-in-Excel-VBA-macro" rel="noreferrer">long term plan</a> past just <a href="https://www.infoq.com/news/2009/11/VBA-VSTO" rel="noreferrer">supporting legacy code</a>. It just <a href="https://www.quora.com/Why-has-Microsoft-stopped-supporting-VBA-And-what-language-will-take-its-place" rel="noreferrer">continues to exist</a> without any major official future iterations or considerations as it relates to <a href="https://stackoverflow.com/questions/41240745/version-control-system-for-excel-vba-code">core</a> <a href="https://continuousdelivery.com/foundations/test-automation/" rel="noreferrer">development</a> <a href="https://www.quora.com/How-can-I-update-a-VBA-program-to-different-users" rel="noreferrer">challenges</a> such as this one.</p>