title: VBA Automation Error (System call failed) while running Excel 2013 macro from Access 2013
body: <p>I have an Access (2013) database that I use to store/process all of our data received from a Qualtrics online survey. The raw data downloaded from Qualtrics is in a csv file that's poorly formatted for importing to Access, so I've got a fairly complex Macro in Excel (2013) that I use to pre-process the data before importing to Access.  </p>
  
  <p>In Access, I use the following code to open the excel file that contains the macro, run the macro, save the workbook, and close it. This had been working well several for several months, but now when I run it, it stops near the end of the Excel Macro with the run time error: -2147417856 Automation error System call failed.</p>
  
  <pre><code>ActivateOrOpenWorkbook WbkName &amp; ".xlsm", strWbkPath
  appExcel.Run ProcName, ProcArg
  
  appExcel.Workbooks(WbkName).Save
  If appExcel.Workbooks.Count = 1 Then
      appExcel.Quit
  Else
      appExcel.Workbooks(WbkName).Close True
  End If
  </code></pre>
  
  <p>ActivateOrOpenWorkbook is just a custom function to do exactly what the name implies, appExcel is the Excel Application. The workbook always opens fine, and the macro begins to run, but it never actually reaches the point where control returns to the Access VBA and saves the workbook.</p>
  
  <p>It does run fine if I open the Workbook before running the Access procedure, insert breakpoints at every major VBA step (in both Access and Excel), and step through the whole thing one Sub at a time.  It just fails if I try to let VBA run it all from start to finish on it's own.</p>
  
  <p>Based on that evidence plus stories of similar problems that I've seen online, I suspect that the error is occurring because the Excel macro is taking too long to run (we recently added some new variables to the Qualtrics survey), and Access is trying to take back control before Excel is finished. I just haven't found any viable way to solve that suspected problem or investigate it further.  </p>
  
  <p>I did try inserting this makeshift Wait routine into my ErrorHandling for the Access Sub, but it didn't work at all, because the error message still popped up in the same amount of time as before.  </p>
  
  <pre><code>If Err = -2147417856 Then
  TWait = Time
  TWait = DateAdd("s", 15, TWait)
  Do Until TNow &gt;= TWait
      TNow = Time
  Loop
  Resume Next
  </code></pre>
  
  <p>Any help will be appreciated!</p>