当我运行代码以从 CMS 报告中检索数据时,如果我单步执行代码,则代码可以工作,但如果我正常运行,它(最终)会失败,并且 MS Access 停止响应。
' 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
用于检查剪贴板的子程序,并在我尝试将数据放入剪贴板之前将其清空:
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&) <> 0 Then
Call apiEmptyClipboard
Call apiCloseClipboard
End If
End Sub
Function ClipboardEmpty() As Boolean
ClipboardEmpty = (CountClipboardFormats() = 0)
End Function
我对对象使用后期绑定,并且安装了 Avaya CMS 16.2。
我尝试设置超时,但没有成功(任一行或两者都无法解决问题)
cmsConnection.lTimeOutSecs = 60
cmsConnection.bTimeOutEnable = False