Tuesday, January 13, 2009

Hybrid - Adding Named Printers control to Reports using VBA

 

Hybrid - Adding Named Printers control to Reports using VBA

Named Printers is a module to allow controlling of the printer and settings used when printing reports.  It was originally developed for v3.00 by me while I was working for Sequel Technology (that's why the tables and calls are prefixed with ST).  Later it was purchased by Great Plains for v5.50 and included in core code (Dynamics.dic) for v6.00 onwards.

Named Printers works for any report that is set up to call Named Printers, but what happens when you want Named Printers control for a report that is currently not supported... Well, you can use VBA to call the appropriate Dexterity sanScript functions via the Continuum Integration Library to add a new Named Printers Task to the Assign Named Printers window.  Then the code can read the setting for that Task and change the application default printer just before the report is printed.  After the report is printer, the correct default printer is restored using the System Default and Company Default printers.  The Company Default printer tasks precedence if one is set up.

This example adds Named Printer control when printing from the Inventory Transaction Inquiry window when using the window print button. The code is configured so that the Printer Task is only available from the Assign Named Printers window while the Inquiry window is open.  When the window is closed the Printer Task is removed and the settings selected are removed.  To make the settings permanent, you will need to comment out the "clean up" script when the window is closed.

NOTE: This customisation uses a method of executing Dexterity sanScript code from VBA which is unsupported by Microsoft.

Example code for v8.0, v9.0 & v10.0 is attached at the bottom of the article.

Please see the "Installation Instructions.txt" file in each version's archive for more information.

Posted: Wednesday, January 14, 2009 10:30 AM by David Musgrave

Developing for Dynamics GP : Hybrid - Adding Named Printers control to Reports using VBA

No comments:

Blog Archive