google-docs

Google Apps Script: How to remove a link from a document

时间秒杀一切 提交于 2020-01-06 18:09:15
问题 I'm having trouble to remove a link from a Text element. Calling .setLinkUrl(null) on it seems to work, but makes the document crash! You can see it happening with this tiny google script: function test() { var body = DocumentApp.getActiveDocument().getBody(); var text = body.appendParagraph("link").editAsText(); text.setLinkUrl(null); } Running it then trying to edit the document gives me a "File unavailable" error. Also tried to set remove the link with .setAttributes , but same error. Is

Google Apps Script: How to remove a link from a document

别等时光非礼了梦想. 提交于 2020-01-06 18:08:09
问题 I'm having trouble to remove a link from a Text element. Calling .setLinkUrl(null) on it seems to work, but makes the document crash! You can see it happening with this tiny google script: function test() { var body = DocumentApp.getActiveDocument().getBody(); var text = body.appendParagraph("link").editAsText(); text.setLinkUrl(null); } Running it then trying to edit the document gives me a "File unavailable" error. Also tried to set remove the link with .setAttributes , but same error. Is

How to make iContact API call from Google scripts

核能气质少年 提交于 2020-01-06 07:58:08
问题 I need to write a function in google scripts that addes a contact to icontact via API. I have the following code which works to change a contact but I am unsuccessful in changing the code to add a contact... Does anybody know how to write the call to add a contact? function sendHttpPost() { var headers= { "API-Username":"XXXXX", "API-AppId":"XXXXXX", "API-Version":"2.0", "API-Password":"XXXXX", "Accept":"application/json"}; var payload = { "contactId":1976438, "email":"schnick@schnack.com",

Tools to reduce generated HTML size

柔情痞子 提交于 2020-01-06 07:00:27
问题 I'm using google docs, and some templates we are using were created using MS-Office. The resulting HTML is fat and ugly, and the 500KB per doc limitation on google makes some cleanup mandatory. I was able to find redundant "style" attributes and move them to some CSS class, and rename the most redundant classes names to shorter ones, which makes me save about 50% of the original size. Are you aware of some existing tools/scripts/lib which could do this painful job for me, or at least help me

Replace first occurrence of text using replaceText(searchPattern, replacement)

无人久伴 提交于 2020-01-06 03:51:29
问题 I am trying to replace the first occurrence of a paragraph in Google Doc using the function replaceText(searchPattern, replacement) , but I can't seem to find the right RegEx expression. If someone could help me I would really appreciate it. body.replaceText("^"+paragraph.getText()+"$"," "); 回答1: The body.ReplaceText() function replaces all instances of a pattern, not just the first instance ( link ). A better option may be to loop through the paragraphs to find the first with matching text,

Insert page break into google document in insertText()

落花浮王杯 提交于 2020-01-06 02:30:52
问题 I'm making a document merge with google apps script and I want to guarantee that each new 'page' will be on an actual new page. I recognize that I could use some sort of for loop and appendParagraph(text).appendPageBreak() but, this could be a 100-200 page merge and it seemed very slow and inefficient. What I'd like to do is just have one .editAsText().setText(text) and be able to just call it once with a huge string and be done. But, the page break seemed difficult and I didn't want to have

Deleting all content down from the second horizontal line in a document

ぐ巨炮叔叔 提交于 2020-01-05 08:57:10
问题 I'm trying to create a script to delete all text/content downwards from a page. Below you can see the current document. Currently, I have the script set-up so that it deletes everything down and including from a text of, "STARTHERE". However, I want it to delete down from the second horizontal line in the image, however, not including the line. Any ideas on how to delete down from the second horizontal line? What does deleteText startOffset and endOffsetInclusive actually mean? Is it like a

Google Doc Script onEdit

隐身守侯 提交于 2020-01-03 03:59:05
问题 I want to build a Google Doc Extension. Google Spreadsheets has an onEdit trigger, Google Documents don't seem to: https://developers.google.com/apps-script/understanding_triggers Is there a way for me to handle user input (typing) cleanly? Thanks! 回答1: Not in Apps Script. If you write an app using the Drive API, you can use the Realtime API https://developers.google.com/drive/realtime/ 来源: https://stackoverflow.com/questions/19781406/google-doc-script-onedit

edit google document remotely

两盒软妹~` 提交于 2020-01-02 07:25:31
问题 I'm trying to add a feature to my website as follows: Clicking a button appends text to a Google document. Obviously I will need to create an Apps Script in the drive. The question is how to trigger the Apps Script from my website. You can assume that I am the owner of the drive/document and so have permissions to edit it in any way I like. I have looked at these topics: Workarounds : How to edit native google documents programatcally?item How to programmatically manipulate native google doc

Google Apps Script To Help Error When Embedding Google Spreadsheet in a Google Site?

安稳与你 提交于 2020-01-01 18:14:13
问题 Spreadsheet A is the master data source for the group that welcomes Newcomers to our little town. It has a ton of very sensitive data in it and cannot be public, not even a little bit. (We're talking about names and birth dates of kids and where they go to school . . . keeping Spreadsheet A secure is mission critical.) So, Spreadsheet B uses an importRange and a query to pull the necessary columns from Spreadsheet A to populate our "Member Directory". Then, I embedded Spreadsheet B in the