google-docs

Trigger Google Apps Script in Spreedsheet from context menu

眉间皱痕 提交于 2021-02-19 06:13:38
问题 I have Google Apps Script in Spreedsheet that works on currently selected row. To run it I have to select this script from script manager. Is it possible to add this script to the context menu or bind to some shourtcut ? 回答1: You can create a menu with button that will run the script that you want using the onOpen function. See the Apps Script documentation. function onOpen() { var sheet = SpreadsheetApp.getActiveSpreadsheet(); var entries = [{ name : "Read Data", functionName : "readRows" }]

Location of a comment in its corresponding Google doc

我怕爱的太早我们不能终老 提交于 2021-02-17 04:32:16
问题 Given a google doc retrieved through the Google docs API and its comments retrived with the Drive API, How do you know where in the document a comment corresponds? I've been inspecting all the fields and couldn't find a relation except the quotedFileContent that contains the commented text in the doc, but this would resolve ambiguously if that text is duplicated. 回答1: You cannot retrieve the location of a comment using Drive API. As you can see in the official documentation, the Comment

Location of a comment in its corresponding Google doc

戏子无情 提交于 2021-02-17 04:29:24
问题 Given a google doc retrieved through the Google docs API and its comments retrived with the Drive API, How do you know where in the document a comment corresponds? I've been inspecting all the fields and couldn't find a relation except the quotedFileContent that contains the commented text in the doc, but this would resolve ambiguously if that text is duplicated. 回答1: You cannot retrieve the location of a comment using Drive API. As you can see in the official documentation, the Comment

Location of a comment in its corresponding Google doc

戏子无情 提交于 2021-02-17 04:26:04
问题 Given a google doc retrieved through the Google docs API and its comments retrived with the Drive API, How do you know where in the document a comment corresponds? I've been inspecting all the fields and couldn't find a relation except the quotedFileContent that contains the commented text in the doc, but this would resolve ambiguously if that text is duplicated. 回答1: You cannot retrieve the location of a comment using Drive API. As you can see in the official documentation, the Comment

Google Apps Script Header/Footer Clear and Replace

被刻印的时光 ゝ 提交于 2021-02-16 15:17:09
问题 I have a script that updates Google Docs' header and footer (by retrieving parameters from the AODocs add-on) when a new document version is published. My problem is that the footer.clear() method doesn't seem to erase the header (or footer) and leaves a carriage return at the top of the section. Subsequent versions keep "growing" in the footer space. Is this a known issue? Am I doing it wrong? (I pull in a line from a template so that I can have pagination, too. Here's a code-snippet for the

How do you change formatting within a google doc for multiple occurrences using findText()?

六眼飞鱼酱① 提交于 2021-02-10 22:26:19
问题 I am trying to find text within a google doc and replace with a subscript notation - replace "a3" with a3 but with the 3 now formatted as a subscript. based on the answer here I wrote some code that is working but only replaces the 1st instance of any occurrence (some are repeated). I wrote the following: for (var k=0; k<subscriptsReplace.length; k++) { subscript = ' a'+subscriptsReplace[k]; find = ' a'+subscriptsReplace[k]+' '; Logger.log(find) var element = body.findText(find); if(element){

How do you change formatting within a google doc for multiple occurrences using findText()?

元气小坏坏 提交于 2021-02-10 22:23:21
问题 I am trying to find text within a google doc and replace with a subscript notation - replace "a3" with a3 but with the 3 now formatted as a subscript. based on the answer here I wrote some code that is working but only replaces the 1st instance of any occurrence (some are repeated). I wrote the following: for (var k=0; k<subscriptsReplace.length; k++) { subscript = ' a'+subscriptsReplace[k]; find = ' a'+subscriptsReplace[k]+' '; Logger.log(find) var element = body.findText(find); if(element){

Insert a block of preformatted text at cursor

和自甴很熟 提交于 2021-02-10 16:15:45
问题 I'm trying to automate some boring action in a documentation I'm writing. I would like to be able to insert at cursor position something like this: HEADING3 Some Text BOLD_TEXT1 2x2 table BOLD_TEXT2 2x2 table BOLD_TEXT2 2x2 table Where BOLD_TEXT has the same style (i.e. text dimension 14, grey color and all caps) and the table is page-wide and has the first row colored (i.e green) while the second column has second row with background color. Is it possible without getting mad? I have not

Insert a block of preformatted text at cursor

萝らか妹 提交于 2021-02-10 16:14:16
问题 I'm trying to automate some boring action in a documentation I'm writing. I would like to be able to insert at cursor position something like this: HEADING3 Some Text BOLD_TEXT1 2x2 table BOLD_TEXT2 2x2 table BOLD_TEXT2 2x2 table Where BOLD_TEXT has the same style (i.e. text dimension 14, grey color and all caps) and the table is page-wide and has the first row colored (i.e green) while the second column has second row with background color. Is it possible without getting mad? I have not

Replace a text keyword with a “Page Break” element in Apps Script

蓝咒 提交于 2021-02-10 13:40:06
问题 I want to replace a specific text keyword with a page break. Here's what I've tried: body.findText("%PAGE_BREAK%").getElement().appendPageBreak() and body.replaceText("%PAGE_BREAK%", "").asBody().appendPageBreak() I'm trying to edit existing documents which have %page_break% somewhere and replace it with an actual page break element. 回答1: The following will suffice under the assumption that "%page_break%" appears either at the end of a paragraph, or in a paragraph of its own. The script