I'm trying to built a script that replace some Data in a Google Document. I'm just observing a problem. The script works well for all the body and the footers from the 2nd to the last page. My first page footer is set as different than the others but i couldn't find a way to modify its content.
Do you have any solutions ? By the way, I'm looking for a way to open the new document in my browser at the end of the script. Any solutions too ? There's a part of my script.
var documentId = DriveApp.getFileById('1mh8yjFpy7NcjB8meXWvn1SKQofjSMcFdPqWBe4GoC14').makeCopy().getId();
var body = DocumentApp.openById(documentId).getBody();
var footer = DocumentApp.openById(documentId).getFooter();
DriveApp.getFileById(documentId).setName('RM_' + RM + '_' + IDEtude + "_" + Prenom + "_" + Nom);
footer.replaceText("{RM_REF}", RM);
footer.replaceText("{PROJECT_REF}", IDEtude);
body.replaceText("{RM_REF}", RM);
body.replaceText("{PROJECT_REF}", IDEtude);
body.replaceText("{NumeroBA}", numBA);
body.replaceText('{PrenomNom}', Prenom + " " +Nom);
body.replaceText('{adresse}', Adresse);
body.replaceText('{code postal et ville}', CP);
body.replaceText('{numero de telephone}', NumTel);
body.replaceText('{CLIENT_COMPANY}', NomClient);
body.replaceText('{DatedeFin}', DatedeFin);
body.replaceText('{DatedeDebut}', DatedeDebut);
body.replaceText('{FaitLe}',Date);
body.replaceText('{Ville}',VilleCdP);
Thanks for your help !
Try to add these three lines in your Code.gs
after the line 37:
first_footer = footer.getParent().getChild(3);
first_footer.replaceText("{RM_REF}", RM);
first_footer.replaceText("{PROJECT_REF}", IDEtude);
...getParent().getChild(3)
— is the hack to get access to a footer on a 'different first page' (probably it's your case)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments