One of my friends asked me about how to directly print the crystal report to the printer using VBA on pressing a button on any of Microsoft Dynamics GP Windows, and I thought I should share this tip:
First, on your VBA project, go to Tools>> References and add a reference to
"Crystal Reports ActiveX Designer Design and Runtime Library"
Place your report in an accessible location to be loaded, then place code below where you need to print the report:
Dim CRApp As New CRAXDDRT.Application
Dim CRReport As New CRAXDDRT.Report
Set CRReport = CRApp.OpenReport("C:\rptAccounts.rpt", 1)
Dim CP As CRAXDDRT.ConnectionProperties
For Each tbl In CRReport.Database.Tables
Set CP = tbl.ConnectionProperties
CP.Item("User ID") = "sa"
CP.Item("Password") = "123"
CP.Item("Data Source") = ".\SQL2005"
CP.Item("Initial Catalog") = "TWO"
Change "C:\rptAccounts.rpt" to your actual report path and enjoy!