I have multiple document as Master Document. If I want to re-use this multiple files, I must edit it one by one, with every document has some text to replace. I try to replace multiple Text at single document with Google APP Script, and work. How to replace multiple text in multiple document with Document ID in the Google Spreadsheet List? There is the script I Try to built.
function replaceText() {
const spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
const sheetIDList = spreadsheet.getSheetByName('RENAME');
const colId = 4;
const firstRowID = 2;
const lastRowId = 17;
const n = lastRowId - firstRowID;
let startRow = firstRowID // Baris awal data DOC ID
var values = sheetIDList.getRange(startRow, colId, n).getDisplayValues();
values.forEach(([docId]) => {
if (!docId) return;
var doc = DocumentApp.openById(docId);
var body = doc.getBody();
body.replaceText("Kepala SMK Negeri 7 Semarang", "Kepala SMK Negeri 3 Jepara");
body.replaceText("SMK Negeri 7 Semarang", "SMK Negeri 3 Jepara");
body.replaceText("Haris Wahyudi, S.Pd., M.Pd.", "SUSWANTO DJONY PURNAWAN, S.Pd., M.Pd");
body.replaceText("19751222 200003 1 002", "19700531 200401 1 001");
body.replaceText("Pembina Tk. I", "Pembina");
body.replaceText("SEKOLAH MENENGAH KEJURUAN NEGERI 7 SEMARANG", "SEKOLAH MENENGAH KEJURUAN NEGERI 3 JEPARA");
});
}