title: Avaya CMS data extraction in vba only works when single stepping
body: <p>When I run my code to retrieve data from a CMS report, if I single step through the code, the code works, but if I run it normally, it (eventually) fails, and MS Access stops responding.</p>
  
  <pre><code>' Sets parameters for report
  cmsReport.SetProperty reportPrompt(1, 1), reportPrompt(1, 2)
  cmsReport.SetProperty reportPrompt(2, 1), reportPrompt(2, 2)
  cmsReport.SetProperty reportPrompt(3, 1), reportPrompt(3, 2)
  ' Runs report and extracts results
  EmptyClipboard
  b = cmsReport.ExportData("", 44, 0, True, True, True)
  Do While ClipboardEmpty
      ' for some reason, avaya doesn't always copy to clipboard, so keep repeating it until it gives up the data!
      b = cmsReport.ExportData("", 44, 0, True, True, True)
  Loop
  </code></pre>
  
  <p>the subroutines used for checking clipboard, and emptying it before I try to get the data into the clipboard:</p>
  
  <pre><code>Private Declare Function apiOpenClipboard Lib "user32" Alias "OpenClipboard" (ByVal hWnd As Long) As Long
  Private Declare Function apiEmptyClipboard Lib "user32" Alias "EmptyClipboard" () As Long
  Private Declare Function apiCloseClipboard Lib "user32" Alias "CloseClipboard" () As Long
  Private Declare Function CountClipboardFormats Lib "user32" () As Long
  
  Sub EmptyClipboard()
  If apiOpenClipboard(0&amp;) &lt;&gt; 0 Then
      Call apiEmptyClipboard
      Call apiCloseClipboard
  End If
  End Sub
  
  Function ClipboardEmpty() As Boolean
  ClipboardEmpty = (CountClipboardFormats() = 0)
  End Function
  </code></pre>
  
  <p>I use late binding for the objects, and I have Avaya CMS 16.2 installed.<br>
  I have tried setting the timeouts, with no success (either line, or both, fails to solve the issue)</p>
  
  <pre><code>cmsConnection.lTimeOutSecs = 60
  cmsConnection.bTimeOutEnable = False
  </code></pre>