đăng 20:32 27 thg 3, 2012 bởi Hai Yen
[
đã cập nhật 07:41 16 thg 9, 2014
]
Nếu tham số đưa vào (file format) không đặc tả thì sẽ in ra màn hình, còn không thì in ra file word hoặc excel Function PrintToFile(AcReportName As String, OutPutFileName As String, Optional FileFormat As String="") Dim tFileFormat As String ' Variable to keep report format type On Error GoTo ErrHandler Select Case FileFormat Case "Excel": tFileFormat = acFormatXLS Case "Word": tFileFormat = acFormatRTF Case "Snapshot": tFileFormat = acFormatSNP Case Else ' Just preview report only End Select If tFileFormat = "" Then ' Open report in preview mode DoCmd.OpenReport AcReportName, acViewPreview Else ' Print directly to file DoCmd.OutputTo acOutputReport, AcReportName, tFileFormat, OutPutFileName, True End If Exit Function ErrHandler: MsgBox "Error raised by " & Err.Number & " code: " & Err.Description End Function
|
|