I searched the internet for a answer but can't find one. I've written a few really basic script in the past for excel, but i'm now using google sheets and want to have a button that hide specified rows, then publish the spreadsheet as a PDF.
I currently have 1 button for hidding rows and 1 button to publish, but i would like to combine them.
Here is what i have. Both scripts work fine alone, but when i run the code below, only the second function seems to work.
/* Hide rows */
function hideRows() {
SpreadsheetApp.getActiveSheet().hideRows(46,160)
}
/* Email Google Spreadsheet as PDF */
function emailGoogleSpreadsheetAsPDF() {
// Send the PDF of the spreadsheet to this email address
var email = "useremail@useremailcom";
// Get the currently active spreadsheet URL (link)
var ss = SpreadsheetApp.getActiveSpreadsheet();
// Subject of email message
var date = Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd");
var subject = "" + ss.getName()+ " - " + date ;
// Email Body can be HTML too
var body = "You can find attached the Daily Status Report";
var blob = DriveApp.getFileById(ss.getId()).getAs("application/pdf");
blob.setName(ss.getName() + ".pdf");
// If allowed to send emails, send the email with the PDF attachment
if (MailApp.getRemainingDailyQuota() > 0)
GmailApp.sendEmail(email, subject, body, {
htmlBody: body,
attachments:[blob]
});
}
Note: I would also like to have the button that call the script to be hidden, can i do it by including the row containing the button in the range of the script ?