title: VBA Copy module from one workbook to another?
body: <p>I am trying to copy a vba module from one workbook to another using the below code.</p>
  
  <pre><code>Dim comp As VBComponent
  Set comp = ThisWorkbook.VBProject.VBComponents("File")
  Workbooks("book2.xlsm").VBProject.VBComponents.Add comp
  </code></pre>
  
  <p>For some reason this gives me an error user defined type not defined on the following line:</p>
  
  <pre><code>Dim comp As VBComponent
  </code></pre>
  
  <p>Please can someone show me where i am going wrong?</p>
  
  <p>Thanks</p>