Google-sheets – Google Sheets macro for printing

google sheetsgoogle-apps-script

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());

  range.activate()

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

}

What am I doing wrong?

Best Answer

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.

Related Topic