Note: This information applies to Jet Professional, Jet Essentials, and Jet Reports
If you write macros in Excel or want to launch Jet from another application, you can launch Excel, update report options, refresh the report and print. Below is some sample code that demonstrates how to do this.
Steps implemented in code:
Start Excel; make it visible and interactive.
Open the Jet Add-in.
Open a Workbook.
Print the Worksheet that contains the report.
Dim XLApp as Object
Set XLApp = New Excel.Application
Workbooks don't necessarily start in a mode that is visible or interactive.
If the user will interact with the workbook, you need to set the following two values:
XLApp.Visible = True
XLApp.Interactive = True
Add-ins do not automatically open when using automation, so the Jet Excel add-in
must be opened manually. You must also open any other add-ins that you need.
XLApp.Application.Workbooks.Open ("C:\program files (x86)\JetReports\jetreports.xlam")
Open the report workbook:
Update the report options. The option values are in single cell named ranges.
XLApp.Application.Workbooks("ReportName.xlsx").Names.Item("DateFilter").RefersToRange.Value = _
Run the jet report.
In Jet Professional 2018 (18.0) and higher, the menu option is named RUN
XLApp.Application.Run "JetReports.xlam!JetMenu", "Run"
In earlier versions, the menu option is named REPORT
XLApp.Application.Run "JetReports.xlam!JetMenu", "Report"
In some cases all the below steps may not be desired.
Choose a worksheet and launch print preview. The user can cause the report to print if desired.
Avoid the message asking if the workbook should be saved by marking it as already saved.
Be careful with this. You are assuming that the workbook does not need to be saved since it is a report
XLApp.Application.Workbooks("ReportName.xlsx").Saved = TRUE