Using a google docs script to find a horizontal rule -
i trying write google docs script locates horizontal rule within google doc. start wrote simple script below determine if cursor placed on horizontal rule or not. cannot seem "gettype()" work, returns "paragraph" not "horizontal_rule"!
function search() { var doc = documentapp.getactivedocument(); var body = doc.getbody(); var cursor = doc.getcursor(); // find location of cursor var element = cursor.getelement(); logger.log(element.gettype()); // use gettype() determine element's type. if (element.gettype() == documentapp.elementtype.horizontal_rule) { body.appendparagraph('the cursor element line.'); } else { body.appendparagraph('the cursor element not line.'); } }
Comments
Post a Comment