title: Creating Excel Files using VB2010
body: <p>I have a form with 1 button to create an Excel file on my desktop.</p>
  
  <p>I get error message:</p>
  
  <blockquote>
    <p>NullReferenceException Was Unhandled<br>
    Object reference not set to an instance of an object</p>
  </blockquote>
  
  <p>and it highlights the code:</p>
  
  <pre><code>WB = excelapp.workbooks.add
  </code></pre>
  
  <p>I did add the reference "Microsoft excel 14.0" and my full code is below:</p>
  
  <pre><code>imports excel = microsoft.office.interop.excel
  
  dim excelapp as excel.application
  dim WB as excel.workbook
  
  sub button1()
  
  WB = excelapp.workbooks.add
  excelapp.visible=true
  
  end sub
  </code></pre>