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.
IMPORTANT NOTE: Jet Reports intends to keep the below command working in future versions
of the Jet add-in. All other menu commands might change. They might work now, but could
break in a future version. Please do not use any other Jet commands in your software.
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