Re: [Apps-Script] Print Sheet Google Sheet Script

116 views
Skip to first unread message

Andrew Roberts

unread,
Nov 15, 2022, 7:43:27 AM11/15/22
to google-apps-sc...@googlegroups.com
I don't think it is possible to print a document directly from Apps Script. You would typically export it as a PDF (manually or programmatically) and print it from there. As a cloud scripting language Apps Script doesn't have much (anything?)to do with your local hardware.

On Tue, 15 Nov 2022 at 08:46, vito gums <vito...@live.co.uk> wrote:
Hi there I am new to google sheets,

I have recorded these steps and in here is a point that I need to print the sheet but it doesn't seem to record that action, the gap in the script is where I need it to print, can anyone help please? Thanks in advance 

function AutoPrintNew() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getRange('A8').activate();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Auto Print'), true);
  spreadsheet.getRange('A1').activate();
  spreadsheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.DOWN).activate();
  var currentCell = spreadsheet.getCurrentCell();
  spreadsheet.getSelection().getNextDataRange(SpreadsheetApp.Direction.NEXT).activate();
  currentCell.activateAsCurrentCell();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Lables'), true);
  spreadsheet.getRange('\'Auto Print\'!A3:B3').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
  spreadsheet.getActiveRangeList().setBorder(false, false, false, false, false, false)
  .setFontColor('#ffffff');
  spreadsheet.getRange('E3:L6').activate();

Print Script here?

   spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Auto Print'), true);
  spreadsheet.getActiveRangeList().clear({contentsOnly: true, skipFilteredRows: true});

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/6c1ad56a-3dde-4775-88fa-eb553defc0fcn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages