in reply to Re: WIN32, OLE, Excel, and Printing
in thread WIN32, OLE, Excel, and Printing
As for the actual loop that prints the reports, see below.Sub PrintOut([From], [To], [Copies], [Preview], [ActivePrinter], [Prin +tToFile], [Collate], [PrToFileName])
As you can see the dialog variable determines whether or not the print dialog will be displayed. Another note that may be important, is that the excel xlDialogPrint object actually prints the active workbook (or doesn't, depending on the user's response) so no call to PrintOut is required. A subsequent call to PrintOut on the same workbook keeps the setting set by xlDialogPrint.# Print the report sub on_winReports_btnPrint_clicked { my ($btn, $win) = @_; my $self = $win->{GUI}; my $tree = $self->get_widget('winReports_treeView'); my $model = $tree->get_model; my $period = $self->get_period; return unless $period; my $criteria = $self->get_criteria; my $dialog = 1; $model->foreach ( sub { my ($model, $path, $iter) = @_; my $class = $model->get($iter, CLASS_COL); my $active = $model->get($iter, ACTIVE_COL); my $header = $model->get($iter, HEADER_COL); if ($active && !$header) { my $options = $self->get_options($class); my $report = GTIMs::Report->new($class, {Period => $period +, Criteria => $criteria, Options => $options}); $report->create; $report->print($dialog); $report->destroy; $dialog = 0; } } ); } #### HERE IS THE NEW PRINT FUNCTION IN GTIMs::Report ##### sub print { my ($self, $dialog) = @_; if ($dialog) { my $dlg = $self->{Excel}->Dialogs(xlDialogPrint); my $result = $dlg->show; } else { $self->{Document}->PrintOut(); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: WIN32, OLE, Excel, and Printing
by Corion (Patriarch) on Aug 21, 2008 at 06:07 UTC |