I am writing a script to populate a cell with some information for a mailer. I'm fairly new to this, so am guessing the coding isn't perfect. However, all I really need to achieve is to get a block of text - and it's pretty much there.
The problem is, that when it returns the text it adds a qutoation at start and at the end.
Can someone let me know how to return the text without this.
function MailerText(strMailer, strName) {
if (strMailer === undefined || strMailer === "Ignore") {return ""};
let varBody
let ss = SpreadsheetApp.getActiveSpreadsheet();
var formS = ss.getSheetByName("Actions");
if (strMailer == 'A Style English') {varBody = formS.getRange('C1').getValue(); varSalutation = formS.getRange('B1').getValue();}
else if (strMailer == 'A Style German - Female') {varBody = formS.getRange('C2').getValue(); varSalutation = formS.getRange('B2').getValue();};
if (varBody == undefined) {return ""};
return varSalutation ' ' strName ',' "\n" "\n" varBody;
}
As requested, here are a few screen shots of the issue:
Image 1: The function call from the cell
Image 2: How it looks in Sheets after the function call
Image 3: What you get when you copy/paste the text into something.
CodePudding user response:
In this case after researching for a while it seems that whenever Sheets detects that there are special characters or line breaks you will get the quotation marks added when the text is copied, there is a similar post about this behavior and it contains a good workaround if you don't mind copying the text to a different cell then you can try this formula on another cell:
=SUBSTITUTE(C609,char(10),char(13))
This would basically copy the text without the special characters on it and when copy/pasted from the cell where the formula is added then you will see that the quotations will no longer be there.