title: How do I import an excel spreadsheet into a Visual Basic Application
body: <p>I have to write an application in Visual Basic.Net that will open an excel file, run through the contents an export a test file for processing. </p>
  
  <p>The application works great for me (Windows 7) but when transferred to a WinXP PC gives the following error: HResult 0X800A03EC</p>
  
  <p>I can replicate this error by making the Excel Application visible so it seems like it is an issue where it can't access the file because it is open. Error occurrs when trying open the workbook.</p>
  
  <p>Original Code </p>
  
  <pre><code>    Dim excel As Excel.Application
      Dim wb As Excel.Workbook
      excel = New Excel.Application
      excel.Visible = False
      excel.UserControl = False
      wb = excel.Workbooks.Open(FileLocation)
      ws = wb.Worksheets(1)
      ws.Activate()
  </code></pre>
  
  <p>Code To Replicate Error</p>
  
  <pre><code>    Dim excel As Excel.Application
      Dim wb As Excel.Workbook
      excel = New Excel.Application
      excel.Visible = True
      excel.UserControl = False
      wb = excel.Workbooks.Open(FileLocation)
      ws = wb.Worksheets(1)
      ws.Activate()
  </code></pre>