I have a problem with google app script I was uploading my files to drive using php, The file is inserting in to drive successfully. But when i want to edit my document to highlight the words using google app script I am getting error, The File Id of google drive and google docs are different, So I am unable to edit the file in google docs using app script. Please look in to my code and suggest me
I am using google docs link to edit but the file id I have with me is drive file id, So suggest me how can i get that
function doGet(param){
var files = DriveApp.getFilesByName('11008.doc');
while (files.hasNext()) {
var file = files.next();
var url = file.getUrl();
url = url.replace("?usp=drivesdk","");
Logger.log(url);
var doc = DocumentApp.openByUrl('https://docs.google.com/document/d/18CEwLeTLwsQ_xR2BLWqs5E1lQrd9SsNuUwlnBpWLQro/edit');
var textToHighlight = 'MA';
var highlightStyle = {};
highlightStyle[DocumentApp.Attribute.FOREGROUND_COLOR] = '#FF0000';
var paras = doc.getParagraphs();
var textLocation = {};
var i;
for (i=0; i<paras.length; ++i) {
textLocation = paras[i].findText(textToHighlight);
if (textLocation != null && textLocation.getStartOffset() != -1) {
textLocation.getElement().setAttributes(textLocation.getStartOffset(),textLocation.getEndOffsetInclusive(), highlightStyle);
}
}
return doc;
}
}