title: Compile throws a "User-defined type not defined" error but does not go to the offending line of code
body: <h2>Symptoms</h2>
  
  <p>This is a symptom specifically when compiling an <strong>Excel VBA project</strong>. The following error occurs:</p>
  
  <p><code>User-defined type not defined</code></p>
  
  <p>However, the code that produces this error is not highlighted by the compiler and so I cannot identify the issue.</p>
  
  <h2>What I already know and have tried</h2>
  
  <p>This is a "User-defined type not defined" error that I have seen before with simple issues such as naming something <code>As Strig</code> instead of <code>As String</code>. However, this particular error is only popping up during the <code>Debug &gt; Compile VBAProject</code> menu option and when the error message box pops up it does not highlight the line of code that the error is occurring in.</p>
  
  <p>After a lot of research I have found that this bug can be related to missing references and I have ruled this out as I have included all needed references and Toolbox objects.</p>
  
  <p>To ensure I wasn't missing any obvious missing <code>Dim</code> statements I have added <code>Option Explicit</code> to all code pages (forms included) to make sure nothing was missing. The error still shows when running a compile.</p>
  
  <p><a href="http://support.microsoft.com/kb/190197" rel="nofollow noreferrer">There is also this known bug</a> that states the issue has been known to happen because of the <strong>VB6</strong> projects using binary compatibility:</p>
  
  <blockquote>
    <p>Turn off Binary Compatibility and compile the project. Visual Basic
    will highlight the line of code that contains the User Defined Type
    that is not defined. After resolving the problem, Binary Compatibility
    can be turned back on.</p>
  </blockquote>
  
  <p>I found this article via this <a href="https://stackoverflow.com/questions/11198853/vb6-user-defined-type-not-defined-error-on-full-compile">Question and Answer</a>, however, I cannot find this option in the standard Excel <strong>VBA</strong> editor.</p>
  
  <h2>Help save mine and others' sanity!</h2>
  
  <p>I know from Google searches and other questions that I am not the only one who has had this issue.</p>
  
  <p>I have tried going through the code manually but there are simply too many lines to feasibly do so.</p>
  
  <p>Is there a way of turning off Binary Compatibility in Excel VBA projects? How do people find this offending line of code if they can't debug to what they need to change? Any help would be lovely!</p>
  
  <p>Thank you in advance.</p>
  
  <p><strong>Edit:</strong> <del>I have found the offending line of code and so my particular issue is solved</del> The problem is still here after removing that particular line - it was a misspelt control name on a form being referenced in its code. This still does not solve the particular issue of how you would go about finding this offending code was the issue. Are we able to find a good way of finding the offending code when this bug happens so others in the future can avoid this agony?</p>