title: Write data from Access to Excel file
body: <p>I am trying to use the following code to write data into an excel file</p>
  
  <pre><code>     Dim objexcel As Excel.Application
                       Dim wbexcel As Excel.Workbook
                       Dim wbExists As Boolean
                       Set objexcel = CreateObject("excel.Application")
                       objexcel.Visible = True
                       On Error GoTo Openwb
                       wbExists = False
                       Set wbexcel = objexcel.Documents.Open("C:\Documents and Settings\TAYYAPP\Desktop\test folder\ERROR REPORT2.xls")
                       wbExists = True
  Openwb:
  
                       On Error GoTo 0
                       If Not wbExists Then
                       Set wbexcel = objexcel.Workbook.Add
                       End If
  </code></pre>
  
  <p>but I'm getting an </p>
  
  <blockquote>
    <p>runtime error object doesn't support property or method</p>
  </blockquote>
  
  <p>in the line</p>
  
  <pre><code>Set wbexcel = objexcel.Workbook.Add
  </code></pre>
  
  <p>I have referenced the Excel object library.</p>