I was recently asked about a forum post of mine from a few years ago. It was about how to call a Dexterity report from Visual Basic for Applications (VBA). I checked the blog and could not find a post that showed the code in its simplest form. So here one is...
This technique used the unsupported method of running Dexterity sanScript by calling the Continuum Integration Library. To use this code you must have VBA or at least the customisation site license registered.
The code can be used to run any report (built-in or custom) that does not use a temporary table. If the report does use a temporary table, then when you run the report without the supporting Dexterity code, the table will be empty and so the report will be missing data.
Here is an example of the code (including getting the Named Printer for Custom Reports).
To define which dictionary the report is in adjust the "in dictionary" clause of the code. To change the context that the entire Dexterity pass through script is executed in un-comment the lines following the "Set Context" comment and adjust accordingly. The syntax for restrictions, sorting by indexes and adding legends are included in the template code and just need to be un-commented.
Have a look at these related posts for more Report Writer and Named Printers & VBA related information:
Hope you find this information useful.
15-Apr-2010: To make the restriction work based on a field on a window, you can either use Dexterity (only if the field exists on the original window) or VBA (must add field to Visual Basic). For example:
Dexterity (table and window field datatypes match):
Commands = Commands & " with restriction 'Field Name' of table Table_Name = 'Field Name' of window 'Window Name' of form 'Form Name' " & vbCrLf
VBA (string field):
Commands = Commands & " with restriction 'Field Name' of table Table_Name = """ & VBA_Field & """ " & vbCrLf
VBA (numeric field):
Commands = Commands & " with restriction 'Field Name' of table Table_Name = " & VBA_Field & " " & vbCrLf
// Copyright © Microsoft Corporation. All Rights Reserved.
// This code released under the terms of the
// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)