Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Replace text in google docs using the cell address of google sheets?

$
0
0

I have a doc that contains text like %A1%, %B3%, %A3%, and so on. I have a Google sheet. I want to replace the text in the Google doc from the Google sheet. The replacement is to be made like this:"%A1% will be replaced by the value in cell (1,1), i.e., the value in range"A1:A1","%C3% will be replaced by the value in cell (3,3), i.e., the value in range"C3:C3" and so on. The following code is just for one cell. I want to loop through all cells in the sheet and make all replacements. Any help will be appreciated.

function myFunction() {  var myDoc = DocumentApp.openById('docID')  var docBody = myDoc.getActiveSection()  var sss = SpreadsheetApp.openById('sheetID');   var x =  sss.getRange("A3:A3").getValues()  docBody.replaceText('%A3%', x)} 

Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>