Procedure Spreadsheet::Print(Workbook, Range, Sheet, ShowPreview, NumberOfCopies, Collate, ActivePrinter)


The procedure Spreadsheet::Print makes it possible to print an Excel or OpenOffice Calc sheet from AIMMS.

        Workbook,         ! (input) scalar string expression
        Range,            ! (input) scalar string expression
        [Sheet],          ! (optional) scalar string expression
        [ShowPreview],    ! (optional) scalar binary expression
        [NumberOfCopies], ! (optional) scalar integer expression
        [Collate],        ! (optional) scalar binary expression
        [ActivePrinter]   ! (optional) scalar string expression




A scalar string expression representing the Excel or Calc workbook. If this argument ends in .ods, OpenOffice Calc is used. Otherwise, Excel is


The range to be printed.


The sheet on which the range lies.


If this argument is 1, Excel or Calc shows a print preview window before printing. The visibility mode of the workbook should be ‘On’ in this case. The default value of this argument is 0. In the preview window, you can decide whether to actually print or to cancel the printing.


The number of copies to print. The default value of this argument is 1.


If this argument is 1, and more than one copy of the sheet is printed, the printed sheets are collated neatly. The default value of this argument is 1.


The user can specify the name of the printer to be used for printing the sheet. The default printer is used by default.

Return Value

The procedure returns 1 on success, or 0 otherwise. In case of an error the pre-defined AIMMS parameter CurrentErrorMessage contains a description of what went wrong.


  • By calling the procedure Spreadsheet::SetActiveSheet you can set the active sheet, after which the optional sheet argument can be omitted in procedures like this one.

  • A call to this procedure with a specified sheet argument does not change the active sheet, except when the workbook does not have an active sheet yet.

  • Upto AIMMS 3.11 this function was known as ExcelPrint, which has become deprecated as of AIMMS 3.12.