Closing the Print Preview in Navision

niimodinniimodin Member Posts: 142
Hello Experts,
I have develop a report for all Vendor Invoices which are due for payment.

I have also manage to migrate this same report in Excel.

But my challenge now is that after the report has been exported, the Print Preview still remains with "Report Generation Completed (0 pages)".

Can someone give me the code to use to automatically close the "Print Preview" after the Excel sheet generation is completed?

My code is below:

[b]Vendor Ledger Entry - OnPreDataItem()[/b]
SETFILTER("Document Type",'Invoice');
SETFILTER("Remaining Amount",'<>0');
//AmountLeft := -"Vendor Ledger Entry"."Remaining Amount";

[b]Vendor Ledger Entry - OnAfterGetRecord()[/b]

IF PrintToExcel THEN BEGIN
  CreateExcelBook;
  CreateExcelData;
  CurrReport.QUIT;
END;

[b]Vendor Ledger Entry - OnPostDataItem()[/b]

CreateExcelBook()

CREATE(Excel);

Excel.Visible(TRUE);

Book := Excel.Workbooks.Add(-4167);
Sheet := Excel.ActiveSheet;
Sheet.Name := 'Purch. Invoices Due for Payment';

[b]CreateExcelData()[/b]

Sheet.Range('A1').Value := 'Purchase Invoices Due for Payment: '+ ExcelReportFilter;
Sheet.Range('A1:F1').Merge;
Sheet.Range('A1').Font.Bold := TRUE;

Sheet.Range('A3').Value := 'Due Date';
Sheet.Range('B3').Value := 'Invoice Date';
Sheet.Range('C3').Value := 'Vendor No';
Sheet.Range('D3').Value := 'Name';
Sheet.Range('E3').Value := 'Currency Code';
Sheet.Range('F3').Value := 'Amount';
Sheet.Range('A3:F3').Font.Bold := TRUE;


WITH "Vendor Ledger Entry" DO BEGIN

SETFILTER("Document Type",'Invoice');
SETFILTER("Remaining Amount",'<>0');


IF FIND('-') THEN  BEGIN

RowNo := '5';

REPEAT

CALCFIELDS("Vendor Ledger Entry"."Remaining Amount");
Sheet.Range('A'+ RowNo).Value := "Vendor Ledger Entry"."Due Date";
Sheet.Range('B'+ RowNo).Value := "Vendor Ledger Entry"."Posting Date";
Sheet.Range('C'+ RowNo).Value := "Vendor Ledger Entry"."Vendor No.";

IF VendorBuffer.GET("Vendor Ledger Entry"."Vendor No.") THEN BEGIN
   Sheet.Range('D'+ RowNo).Value := VendorBuffer.Name
END;

IF "Vendor Ledger Entry"."Currency Code" <>'' THEN BEGIN
Sheet.Range('E'+ RowNo).Value := "Vendor Ledger Entry"."Currency Code"
END
ELSE BEGIN
   Sheet.Range('E'+ RowNo).Value := 'GHC'
END;

Sheet.Range('F'+ RowNo).Value := FORMAT(-"Vendor Ledger Entry"."Remaining Amount");

RowNo := INCSTR(RowNo);


UNTIL NEXT = 0;


END;

MESSAGE('Data Transfer completed');

END;

Comments

  • MBergerMBerger Member Posts: 413
    set the "Processing Only" Property of the report to true.
Sign In or Register to comment.