google-apps-script

Run Google Sheets Add-On as different user

懵懂的女人 提交于 2021-02-08 09:53:39
问题 I have two sheets as "Enquiry" and "Master" with owner as "Admin". In enquiry sheet, I protected few columns and shared across users. Users enter data in enquiry sheet and click on plugin (Add-on). The plugin will copy data to master sheet and enters some data in locked cells. Plugin (Add-on) is throwing error because it is not able to edit locked cells. So I want the plugin (Add-on) to run with Admin account rather than user account or any other way to achieve this solution. Note: Admin and

Run Google Sheets Add-On as different user

情到浓时终转凉″ 提交于 2021-02-08 09:53:39
问题 I have two sheets as "Enquiry" and "Master" with owner as "Admin". In enquiry sheet, I protected few columns and shared across users. Users enter data in enquiry sheet and click on plugin (Add-on). The plugin will copy data to master sheet and enters some data in locked cells. Plugin (Add-on) is throwing error because it is not able to edit locked cells. So I want the plugin (Add-on) to run with Admin account rather than user account or any other way to achieve this solution. Note: Admin and

Google apps script: How to horizontally align an inlineImage

淺唱寂寞╮ 提交于 2021-02-08 09:29:45
问题 I have the following code, which is part of a larger program. I am trying to insert an image from my Google drive into a google doc and have it resized and centered. So far I am able to get the program to insert the image and resize it, but I do not know how to center an inlineImage. I am new to using google apps script and I have basically been copying other people's examples and modifying them. Your help would be appreciated. Let me know if I need to clarify. Again, I am trying to CENTER

Container-bound script deployed as Web App returns 404 (not found)

独自空忆成欢 提交于 2021-02-08 09:23:58
问题 I created a Spreadsheet-bound script with a single function: function doGet() { Logger.log("test"); } Then I deploy with: Execute as me, and Access - anyone, even anonymous. However, going to published site fails with an error "Sorry, unable to open the file at this time." (or if accessed via curl - returns 404). Exactly the same procedure works in standalone scripts. Is there a limitation or a gotcha about container-bound scripts? 回答1: This may be a bug. The published endpoint URL returned

Automating named Range function in google sheets

删除回忆录丶 提交于 2021-02-08 09:14:51
问题 Context So I have a spreadsheet with 11+ sheets, though will be adding more later. I want to dynamically name the columns using named range. I created a macro script and have been using this. Only the problem is for every sheet, I have to go to the script and change the name of the named range: function NamedRanges() { var spreadsheet = SpreadsheetApp.getActive(); spreadsheet.setNamedRange('TrainlineDate', spreadsheet.getRange('A:A')); spreadsheet.setNamedRange('TrainlinePrice', spreadsheet

Automating named Range function in google sheets

浪子不回头ぞ 提交于 2021-02-08 09:08:47
问题 Context So I have a spreadsheet with 11+ sheets, though will be adding more later. I want to dynamically name the columns using named range. I created a macro script and have been using this. Only the problem is for every sheet, I have to go to the script and change the name of the named range: function NamedRanges() { var spreadsheet = SpreadsheetApp.getActive(); spreadsheet.setNamedRange('TrainlineDate', spreadsheet.getRange('A:A')); spreadsheet.setNamedRange('TrainlinePrice', spreadsheet

Automating named Range function in google sheets

只愿长相守 提交于 2021-02-08 09:08:33
问题 Context So I have a spreadsheet with 11+ sheets, though will be adding more later. I want to dynamically name the columns using named range. I created a macro script and have been using this. Only the problem is for every sheet, I have to go to the script and change the name of the named range: function NamedRanges() { var spreadsheet = SpreadsheetApp.getActive(); spreadsheet.setNamedRange('TrainlineDate', spreadsheet.getRange('A:A')); spreadsheet.setNamedRange('TrainlinePrice', spreadsheet

Remove all grouped rows / columns in a spreadsheet

岁酱吖の 提交于 2021-02-08 08:54:29
问题 I have a Google Sheet that does dynamic grouping with a script. I am looking for a function that gets rid of all those Groups in the sheet again. Similar to expandAllColumnGroups, I would like to have a function called removeAllColumnGroups - but it seems there is no such function available. My current approach is very slow and cumbersome. I did quite some research but could not even find a way to get all the columnGroups or at least the start-column-IDs in a sheet, so I iterate over every

Active Sheet always being leftmost sheet on Google Sheets

陌路散爱 提交于 2021-02-08 08:52:42
问题 Continuation from the previous question: Detect Note changes with onChange I know that this is a duplicate question, but the answers from the questions similar to it have not worked for me. Google App Script getActiveSheet returns leftmost sheet, not active sheet function createSpreadsheetOpenTrigger() { var ss = SpreadsheetApp.getActive(); ScriptApp.newTrigger('onChange') .forSpreadsheet(ss) .onChange() .create(); } function onChange(e) { var ss = SpreadsheetApp.getActive().getActiveSheet();

How to change only the *selected* text to uppercase, not the entire paragraph in which the selection exists

℡╲_俬逩灬. 提交于 2021-02-08 08:25:23
问题 In Google docs, this function changes the selected text to black function selectedFontColorBlack() { // DocumentApp.getUi().alert('selectedFontColorBlack'); var sel = DocumentApp.getActiveDocument().getSelection(); var elements = sel.getRangeElements(); for (var i = 0; i < elements.length; i++) { var element = elements[i]; // Only modify elements that can be edited as text; skip images and other non-text elements. if(element.getElement().editAsText) { var text = element.getElement()