A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
Platform : PC desktop
Host: Word
Office version number: Microsoft® Word for Microsoft 365 MSO (Version 2404 Build 16.0.17531.20140) 64-bit
Operating System: Microsoft Windows 11 pro.
Hi team,
I am facing an issue while using the Office.js API to insert and retrieve an \
tag in a Word document. The id attribute of the \ tag is not preserved, and the tag is placed under a different \
upon retrieval.
Below are the details of the problem and the code snippets I am using.
To Insert hr Tag:-
var selection = context.document.getSelection();
const pgCC = selection.insertContentControl();
var html = `<div id="pageNum"><h5 align="center" style="color:black">#</h5><hr id="${pgCC.tag}" style="margin-top: -22px;"></div>`;
pgCC.insertHtml(html, Word.InsertLocation.replace);
To retrieve hr Tag:-
var body = context.document.body;
var bodyHtml = body.getHtml();
await context.sync();
var parser = new DOMParser();
var doc = parser.parseFromString(bodyHtml.value, "text/html");
Issue:-
1.Tag Placement: When retrieving the HTML, the \
tag is placed under a different \
than the one I inserted. It does not maintain the same structure.
2.ID Attribute Missing: The id attribute of the \
tag is missing when I retrieve it back. It seems that the id assigned during insertion is not preserved.
Have attached Snapshot of doc for reference.
Could you please assist me with this issue and provide a proper resolution? Additionally, let me know if I'm doing anything incorrectly or if I should try a different approach.
Platform : PC desktop Host: Word Office version number: Microsoft® Word for Microsoft 365 MSO (Version 2404 Build 16.0.17531.20140) 64-bit Operating System: Microsoft Windows 11 pro.
Hi team, I am facing an issue while using the Office.js API to insert and retrieve an \
tag in a Word document. The id attribute of the \
tag is not preserved, and the tag is placed under a different \
Below are the details of the problem and the code snippets I am using.
To Insert hr Tag:-
To retrieve hr Tag:-
Issue:- 1.Tag Placement: When retrieving the HTML, the \
tag is placed under a different \
2.ID Attribute Missing: The id attribute of the \
tag is missing when I retrieve it back. It seems that the id assigned during insertion is not preserved.
Have attached Snapshot of doc for reference.
Could you please assist me with this issue and provide a proper resolution? Additionally, let me know if I'm doing anything incorrectly or if I should try a different approach.
Thanks.
I'm bit surprised to see the status of the ticket, as it hasn't been assigned to anyone yet.