"How to change the text in a bookmark"

I want to replace the text entered in the bookmark after importing bookmarks in the office.
oDocument.BookmarkRange(‘title’)

Is there a separate object like replace?
Or if I want to delete the text in the bookmark and insert new text?

Hello @Hyun

Do you mean the name of a bookmark?

If so then the only way is to get range of a bookmark, delete old one and add new on the same range:

    var oDocument = Api.GetDocument(); 
    var oRange = oDocument.GetBookmarkRange("<current_bookmark_name>");
    oDocument.DeleteBookmark("<current_bookmark_name>");
    oRange.AddBookmark("<new_bookmark_name>");

Methods used are GetBookmarkRange, DeleteBookmark and AddBookmark.

Add Only Book Mark Without Text and Witout ContentControls

function Referenceclick(ctrl) {
clickCounter++;

var LocationID = document.getElementById("ddlContentType").options[document.getElementById("ddlContentType").selectedIndex].text;

var bookmarkName = LocationID + "_Enforce" + clickCounter;

GetLocationPoints(window.parent.parent.parent.document.getElementById('hdnDevid').value);

var arrDocuments = [{
    "Props": {
        "Id": 7,
        "Lock": 0
    },
    "Script": `var oParagraph = Api.CreateParagraph();
               oParagraph.AddText(' ');
               Api.GetDocument().InsertContent([oParagraph]);
               var oRange = oParagraph.GetRange(0, 1);
               oRange.AddBookmark('${bookmarkName}');`
}];

window.Asc.plugin.executeMethod("InsertAndReplaceContentControls", [arrDocuments]);

window.Asc.plugin.executeMethod("RemoveContentControl", [7]); 


}

Hello @Ram21

As I can see you’ve created separate topic with this solution.

Yes @Constantine Please Replay. And Thanks for Coordination

Closing this topic as the original poster did not return a feedback.