office365 - Can not insert text in bookmark in word document using office.js for office add-in development -
i developing add-in word.the main task populate bookmarks in document data database.in office.js have found bookmark can accessed range object , using "rangeobject.inserttext(text, insertlocation)" method inserting data bookmark.but problem 2nd parameter insertlocation value can 'replace', 'start', 'end', 'before' or 'after'.which appends data before or after bookmark.like - image 1 (current result using insertlocation value 'end')
using insertlocation value 'replace' replaces whole bookmark , deletes bookmark document!.so want insert text in bookmark this- image 2 (desired result)
note: have read these bookmark value later.so no bookmark can deleted.and using 1.4 beta version of office.js api purpose.
here code-
word.run(function (context) { var doc = context.document; //get bookmark range name var bookmarkrange = doc.getbookmarkrangeornullobject("cscasenumber01"); //insert data bookmarkrange.inserttext("test data",'end'); // synchronize document state executing queued commands, return context.sync(); }).catch(errorhandler);
thanks using our preview apis. found bug on it! repro behavior. , yes semantics before, start, end, after clear on api.
- "start" , "end" insert locations imply insertions within boundaries of calling range, on case means if use of bookmark needs expanded whatever inserted.
- on other hand "before"/"after" imply inserting outside boundaries of range.
- finally, replace should replace bookmark whatever text supplied parameter.
we'll fixed, although don't have clear timeline on this. thank you.
Comments
Post a Comment