title: How to copy an input form to a newly created workbook in VBA
body: <p>I realize it was not clear due to copying a part of the macro. Below macro, which starts with the new WB, gives an error 424 object required. checking in manual mode the ProjectWB and SourceWB are loaded correctly.</p>
  
  <pre><code>Sub Copy_Form_to_new_WB()
     ProjectWB = ActiveWorkbook.Name
     SourceWB = "Interpretation Analysis 2.0.xlsm"
     SourceWB.VBProject.VBComponents("Input_Analysis_Form").Export_ 
         "Input_Analysis_Form.frm"
     ProjectWB.VBProject.VBComponents.Import "Input_Analysis_Form.frm"
     Kill "Input_Analysis_Form.frm"
     Kill "Input_Analysis_Form.frx"
  End Sub
  </code></pre>
  
  <p>In the case, I dim both ProjectWB and SourceWB I get the error Compile error: invalid qualifier. and the ProjectWB in line 8 is highlighted</p>
  
  <pre><code>Sub Copy_Form_to_new_WB()
    Dim SourceWB As Integer
    Dim ProjectWB As Integer
    ProjectWB = ActiveWorkbook.Name
    SourceWB = "Interpretation Analysis 2.0.xlsm"
    SourceWB.VBProject.VBComponents("Input_Analysis_Form").Export_ 
       "Input_Analysis_Form.frm"
    ProjectWB.VBProject.VBComponents.Import "Input_Analysis_Form.frm"
   Kill "Input_Analysis_Form.frm"
   Kill "Input_Analysis_Form.frx"
  End Sub
  </code></pre>
  
  <p>What is going wrong?</p>
  
  <hr>
  
  <p><strong>Original question:</strong></p>
  
  <p>In a macro, I'm creating a new workbook which works ok. Now I want to copy an input form from the existing workbook to the new. Checking the Internet I found some bits and parts. To be clear I've copied two parts of the macro.  </p>
  
  <pre><code>Dim SourceWB As Workbook
  Dim ProjectWB As Workbook
  SourceWB = ActiveWorkbook.Name
  'now the part to create the new workbook when this is active
  ProjectWB = ActiveWorkbook.Name
  SourceWB.VBProject.VBComponents("Input_Analysis_Form").Export_ 
  "Input_Analysis_Form.frm"
  DestinationWB.VBProject.VBComponents.Import "Input_Analysis_Form.frm"
  Kill "Input_Analysis_Form.frm"
  Kill "Input_Analysis_Form.frx"
  </code></pre>
  
  <p>Now I get run time error 91 "object variable or with block not set"
  what would be the correct way to do this.</p>