以下のリンクのページから「VB.NET (VB) Windows Sample Applications for use in Microsoft Visual .Net 2002 and Later.」をクリックして、net_win_smpl.exe をダウンロードします。
http://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports+for+.NET+SDK+Samples
以下のフォルダに解凍後、vbnet_win_printtoprinter.zip ファイルを解凍します。
C:\Crystal\CRNET
Microsoft Visual Stuido 2010(2012 が準備できていないため) でプロジェクトファイル (PrintToPrinter.sln) を開きます。
変換後、コード修正なしで、そのまま実行してプリンタへ印刷されることを確認しました。
このサンプルコードでは、コマンドボタンに以下の記述がございます。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
''Create an instance of the Income Statement report.
crReportDocument = New Income_Statement()
''Use error handling in case an error occurs
Try
''Set the printer name to print the report to. By default the sample
''report does not have a defult printer specified. This will tell the
''engine to use the specified printer to print the report. Print out
''a test page (from Printer properties) to get the correct value.
crReportDocument.PrintOptions.PrinterName = "\\server\myprinter"
''Start the printing process. Provide details of the print job
''using the arguments.
crReportDocument.PrintToPrinter(1, True, 1, 1)
''Let the user know that the print job is completed.
MessageBox.Show("Report finished printing!")
Catch err As Exception
MessageBox.Show(err.ToString())
End Try
End Sub
ご提示いだいたエラーですが、動作環境 (Windows)、Crystal Reports ランタイム、実行ファイルのそれぞれの 32 ビット、64 ビットに不一致が存在しないでしょうか?
ちなみ以下の環境でサンプルコードが動作しました。
- Windows 7 64bit
- VS 2010 コンパイルプラットフォーム AnyCPU
- SAP Crystal Reports runtime engine for .NET Framework (64-bit) 13.0.14.1720
- SAP Crystal reports, version for Microsoft Visual Studio 13.0.14.1720
Yoshi