Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Trouble Google Script in Sheets to Print from A1 to cell that contains text "stop print". sheet.setPrintArea not a function- anything similar?

$
0
0

I've been working with both ChatGPT and Google Bard trying to learn how to do this.

It seems that sheet.setPrintArea is not a function nor does there seem to be one similar.

I did a search on developers.google with no results- am I missing an option or is this just not possible?

I'm trying to create this script because the number of rows changes every time I use this sheet.

function printRange() {// Declare variablesvar spreadsheet = SpreadsheetApp.openById("xxxxxx");var sheet = spreadsheet.getSheetByName("Invoice");var rng = sheet.getRange("A1");var strStopPrint = "stop print";

// Find the cell that contains "stop print"var stopPrintCell = sheet.createTextFinder(strStopPrint).findNext();

// Get the range from A1 to the cell containing "stop print"var printRange = sheet.getRange(rng.getRow(), rng.getColumn(), stopPrintCell.getRow() - rng.getRow() + 1, stopPrintCell.getColumn());

// Set the range as the print areasheet.setPrintArea(printRange.getA1Notation());

// Print the sheetsheet.print();}


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>