Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Printing to File Automation

edited October 2003 in General
RB v 6.03 Enterprise

I have a few questions about printing to file.

Is there any way to control the default settings of the print dialog so that
the default file type, and file name can be set?

Also, is it possible to detect when a user has printed to a file so that the
file that has been printed to can automatically be opened?

I know how to open a file using shell commands.

What I would like to do is when the user click the print to file checkmark.
The file type (Excel) will already be selected and a file path and name will
already be selected so that all the user has to do is click 'OK' and they
are done. Then after the report has been printed to file it automatically
opens the file.

Bill

Comments

  • edited October 2003
    Hi Bill,

    1. Unfortunately, the default file type selected in the printdialog is hard
    coded to be the first item in the list. It is possible to customize any of
    the forms in ReportBuilder so you could create a copy of the ppPDlg.pas file
    and add your own code to make it default to another file type. You will
    want to check out the SetFileDeviceType method and change the first two
    lines to something similare to what I have below:

    if (cbxPrintToFileTypes.Items.Count > 0 and cbxPrintToFileTypes.Items.Count
    <= 3) then
    cbxPrintToFileTypes.ItemIndex := 3

    2. You can use the Report.AfterPrint event to see if it was printed to file
    by checking if the filedevice is nil:

    procedure TForm1.ppReport1AfterPrint(Sender: TObject);
    begin

    if (ppReport1.FileDevice <> nil) then
    ShowMessage('Report was printed to file');

    end;

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2003
    Thanks Nico

  • edited October 2003
    If you are using TExtraDevices you can check out the demo program which does
    both of these things. The demo is at www.waler.com/download.htm

    James Waler
    Waler Ltd
    http://www.waler.com
  • edited October 2003
    Thanks James! And yes I do use TExtraDevices!
This discussion has been closed.