对象 文件过滤器 描述
ExportFormats(1) *.htm, *.html HTML
ExportFormats(2) *.htm, *.html Unicode HTML
ExportFormats(3) *.txt Text
ExportFormats(4) *.txt Unicode Text
Private Sub DataReport_ProcessingTimeout(ByVal Seconds As Long, _
Cancel As Boolean, ByVal JobType As MSDataReportLib.AsyncTypeConstants, _
ByVal Cookie As Long)
Select Case Seconds
Case 30
If MsgBox("This has taken " & Seconds & "seconds. Cancel?", _
vbRetryCancel) = vbCancel Then
Cancel = True
End If
Case 45
If MsgBox("This has taken " & Seconds & "seconds. Cancel?", _
vbRetryCancel) = vbCancel Then
Cancel = True
End If
Case 60
'60秒钟后自动取消。
Cancel = True
End Select
End Sub
注意 并不保证在上面指定的间隔会发生 ProcessingTimeout 事件。例如,在后台运行的其他的 Visual Basic 代码可能会阻止这一事件的发生。在那种情况下,将 Case 语句设置为一个范围内的值;当该事件发生时,将一个模块级标志设置为 True,并在随后发生的事件中检查它。
Private Sub DataReport_Error(ByVal JobType As _
MSDataReportLib.AsyncTypeConstants, ByVal Cookie As Long, _
ByVal ErrObj As MSDataReportLib.RptError, ShowError As Boolean)
Select Case JobType ' The JobType identifies the process.
Case rptAsyncPrint
' 此处捕获 PrintReport 错误。
Case rptAsyncReport
' 此处捕获 ExportReport 错误。
End Select
End Sub
也可以使用 Error 事件捕获特定的情况,例如计算机上缺少打印机,如下面的代码中所示:
Private Sub DataReport_Error(ByVal JobType As _
MSDataReportLib.AsyncTypeConstants, ByVal Cookie As Long, _
ByVal ErrObj As MSDataReportLib.RptError, ShowError As Boolean)
Case rptErrPrinterInfo ' 8555
MsgBox "A printing error has occurred. " & _
"You may not have a Printer installed."
ShowError = False
Exit Sub
Case Else
' 此处处理其他情况。
ShowError = True
End Select
End Sub