I wrote the next macro, but isn't working.

For example: I have a button on the sheet (invoerblad) for printing, the button must print the sheet (Printblad), and when the print action is finished, it should return to the sheet (invoerblad).

function PrintSummary() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet().getName()
  var tempRange = ss.getSheetByName("Printblad").getRange(1,1, ss.getLastRow(), ss.getLastColumn());

  var bottomBuffer = 46;    // The amount of rows at the bottom of the sheet to ignore
  var rightBuffer = 4;         // The amount of rows at the right of the sheet to ignore
  var numRows = tempRange.getNumRows() - bottomBuffer;
  var numCols = tempRange.getNumColumns()  - rightBuffer;

  var range = ss.getSheetByName("Printblad").getRange(1,1, ss.getLastRow(), ss.getLastColumn());


  // Run print operation
  // Options: Selection
  //                    No Gridlines
  // Paper Size:  A4
  // Layout:        Fit to Width
  //                    Landscape


What am I doing wrong?

1 Answer 1


Your are missing to use an API like Google Cloud Printer to create and send a print job to your printer.

IMHO the details about this are far a way from the scope of this site. First read the docs then if you need further help consider to post your follow-up question on Stack Overflow.

  • Google Cloud Print is not supported as of December 31, 2020. Also, the “Save to Drive” option won't be available for Windows, MacOS, and Linux devices but you can save documents to Google Drive from print preview. In terms of an equivalent to Cloud Print, Google suggests "printing with a printing partner", such as Directprint.io, LRS, NT-ware, PaperCut, Pharos, PrinterLogic, Printix, Y Soft. Doc Ref
    – Tedinoz
    Nov 8, 2021 at 21:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.