Sign Up for Training |
Jet Express Support |
Jet Reports Company Site
Jet 365 Financials
Jet Professional
Jet Enterprise
Downloads
Community
Submit a Request
Give Feedback

Launching Jet Reports from VBA


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:

  1. Start Excel; make it visible and interactive.

  2. Open the Jet Add-in.

  3. Open a Workbook.

  4. Update Options.

  5. Run Jet/Report.

  6. Print the Worksheet that contains the report.

  7. Close Excel.

Sub JetUpdate()

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:

XLApp.Application.Workbooks.Open ("ReportName.xlsx")

 

Update the report options. The option values are in single cell named ranges.

XLApp.Application.Workbooks("ReportName.xlsx").Names.Item("DateFilter").RefersToRange.Value = _

"1/1/2004..3/31/2004"

 

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.

XLApp.Application.Workbooks("ReportName.xlsx").PrintPreview

 

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

template.

XLApp.Application.Workbooks("ReportName.xlsx").Saved = TRUE

 

Close Excel

XLApp.Quit

End Sub

 
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments